From 3156764265e26503d7a5f462ab653e441a8815e4 Mon Sep 17 00:00:00 2001 From: Martin Labsch Date: Fri, 9 Oct 2020 15:17:46 +0200 Subject: [PATCH] fix stack overflow on windows x64 --- src/thread.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/thread.cpp b/src/thread.cpp index 539622b9..bd3af0d8 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -63,11 +63,18 @@ void zmq::thread_t::start (thread_fn *tfn_, void *arg_, const char *name_) _arg = arg_; if (name_) strncpy (_name, name_, sizeof (_name) - 1); + + // set default stack size to 4MB to avoid std::map stack overflow on x64 + unsigned int stack = 0; +#if defined _WIN64 + stack = 0x400000; +#endif + #if defined _WIN32_WCE _descriptor = - (HANDLE) CreateThread (NULL, 0, &::thread_routine, this, 0, &_thread_id); + (HANDLE) CreateThread (NULL, stack, &::thread_routine, this, 0, &_thread_id); #else - _descriptor = (HANDLE) _beginthreadex (NULL, 0, &::thread_routine, this, 0, + _descriptor = (HANDLE) _beginthreadex (NULL, stack, &::thread_routine, this, 0, &_thread_id); #endif win_assert (_descriptor != NULL);