Skip to content

Commit

Permalink
Merge pull request #4060 from martin-ksti/fix-stack-overflow-on-windo…
Browse files Browse the repository at this point in the history
…ws-x64

fix stack overflow on windows x64
  • Loading branch information
bluca committed Oct 9, 2020
2 parents 4f6d94d + 3156764 commit f578b26
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f578b26

Please sign in to comment.