Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix stack overflow on windows x64 #4060

Merged
merged 1 commit into from
Oct 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this fix is only relevant for VS2010, shouldn't this be restricted to that version? Sticking with the default if possible seems to be desirable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you're right. at the moment I have no way to making the change and I don't know if I will ever have that option.

#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