[PATCH] Fix issue #687 (test_eh_thread)
authorVladislav Shchapov <phprus@gmail.com>
Thu, 23 Dec 2021 12:39:11 +0000 (17:39 +0500)
committerPeter Michael Green <plugwash@raspbian.org>
Fri, 1 Jul 2022 09:58:06 +0000 (10:58 +0100)
Signed-off-by: Vladislav Shchapov <phprus@gmail.com>
Gbp-Pq: Name 8f78aa096459b8ea0fcb54d2f0854f1889043f5d.patch

test/tbb/test_eh_thread.cpp

index aa6d764d01248e6606a72775c9824fdf8767c168..af291f4830559da32f28ae1ab21e03243490122c 100644 (file)
@@ -36,6 +36,7 @@
 // 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>
@@ -73,7 +74,8 @@ public:
         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;
         }
     }