fix(src/util): make sure thread stack size is > LEAN_STACK_BUFFER_SPACE

This commit is contained in:
Leonardo de Moura 2016-12-03 11:55:31 -08:00
parent 8e64665259
commit 80d247eaff
3 changed files with 6 additions and 5 deletions

View file

@ -11,7 +11,6 @@ Author: Leonardo de Moura
#include "util/exception.h"
#if !defined(LEAN_USE_SPLIT_STACK)
#if defined(LEAN_WINDOWS)
// no extra included needed so far
#elif defined(__APPLE__)
@ -21,8 +20,6 @@ Author: Leonardo de Moura
#include <sys/resource.h> // NOLINT
#endif
#define LEAN_MIN_STACK_SPACE 128*1024 // 128 Kb
namespace lean {
void throw_get_stack_size_failed() {
throw exception("failed to retrieve thread stack size");
@ -92,7 +89,7 @@ size_t get_available_stack_size() {
void check_stack(char const * component_name) {
if (!g_stack_info_init)
save_stack_info(false);
if (get_used_stack_size() + LEAN_MIN_STACK_SPACE > g_stack_size)
if (get_used_stack_size() + LEAN_STACK_BUFFER_SPACE > g_stack_size)
throw stack_space_exception(component_name);
}
}

View file

@ -20,7 +20,7 @@ namespace lean {
size_t lthread::m_thread_stack_size = LEAN_DEFAULT_THREAD_STACK_SIZE;
void lthread::set_thread_stack_size(size_t sz) {
m_thread_stack_size = sz;
m_thread_stack_size = sz + LEAN_STACK_BUFFER_SPACE;
}
size_t lthread::get_thread_stack_size() {

View file

@ -7,6 +7,10 @@ Author: Leonardo de Moura
#pragma once
#include <iostream>
#ifndef LEAN_STACK_BUFFER_SPACE
#define LEAN_STACK_BUFFER_SPACE 128*1024 // 128 Kb
#endif
#if defined(LEAN_MULTI_THREAD)
#include <thread>
#include <mutex>