// TODO: enable limitThreads with sanitizer under docker
#if TBB_USE_EXCEPTIONS && !_WIN32 && !__ANDROID__
+#include <limits.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
mValid = false;
pthread_attr_t attr;
// Limit the stack size not to consume all virtual memory on 32 bit platforms.
- if (pthread_attr_init(&attr) == 0 && pthread_attr_setstacksize(&attr, 100*1024) == 0) {
+ std::size_t stacksize = utils::max(128*1024, PTHREAD_STACK_MIN);
+ if (pthread_attr_init(&attr) == 0 && pthread_attr_setstacksize(&attr, stacksize) == 0) {
mValid = pthread_create(&mHandle, &attr, thread_routine, /* arg = */ nullptr) == 0;
}
}