-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Visual Studio 2012 x64 Unhandled Exception Error #2344
Comments
It's all working fine on Linux, OSX, BSDs and even in the Windows CI which uses VS2015 I think: https://ci.appveyor.com/project/zeromq/libzmq/build/build-1038/job/cmao6jfotef1j6qa So I assume it's a problem with the VS2012 configuration. Sorry but I really know nothing about Visual Studio, hopefully a Windows developer can help. If you know VS and can find the issue please do send a PR. |
I'd give it a look but I'm AFK for another week. I wouldn't rule out an issue in the code, especially given that CMake and VS projects give same result. There is a lot of conditionality in the sources. |
Thanks! |
@danieljbarber I've compiled x64 version on VS 2012, ran your program and indeed there's an exception. |
@danieljbarber @bluca @evoskuil
That's one part of the issue, second one, the main culprit, is:
It allocates from stack two
|
Great analysis. Could you please send a PR to add a note to the INSTALL file document in the Windows section to suggest increasing the stack? This way it's documented and it's easier for users. |
Crazy. I run VS2013 - very curious to know if this is still an issue, since I use std::map for other stuff. |
@evoskuil Here's a test which you can run:
Start debugging, add esp/rsp register to Watch (32/64 bit). |
@bluca @evoskuil @danieljbarber Sure, I'll add PR. But I don't know should I put that on Windows it is recommended to always increase stack size from default, just for VS 2012 or only when stack overflow is noticed? Also I haven't tested VS 2013. |
Perhaps rather than indicating it's mandatory, simply stating that with that version of VS there might be these kind of problems, and this is the right workaround |
I'll give it a look. |
RSP changes (decreases) 8 bytes upon stepping into |
@evoskuil Step one more time. When you step into |
okay, 128:
|
296 bytes. That means |
Fixed by #2532 |
This issue is also seen with VS2010 Win64, where std::map is presumably having the same issue, though the code is slightly different. While I am not quite sure the following workaround deserves a PR (due to introducing an extra dependency), I will put it here for those who may be hitting this too (for example, being in the same situation as me: VS2010 Win64, no chance to increase stack size since what I do is a DLL and setting stack size is only done at process level, which is out of my control): WORKAROUND: boost::container::map seems to be a drop-in replacement for std::map, therefore, if you already use Boost, or at least have it installed and are allowed to use it in your project, just use something like this:
Cheers. Sergey. |
Sorry I'm not faimiliar at all with Windows - why is increasing the stack size not an option? |
Stack is an attribute of a code execution, i.e. running process or a light-weight process, also known as thread. What I am developing is a DLL, and DLL is not a thread or a process, and won't be unless it is dynamically loaded and called by a running process - but then it will be running in context of a calling process, hence will have the stack of calling process. it is identical to what shared library on Unix/Linux looks like. similar topic discussed here: while there IS a way to set stack size for a process (using "The Microsoft COFF Binary File Editor (EDITBIN.EXE)" from Visual Studio), in my case this is highly discouraged way of solving stack overflow, because a) this may be rendering host application (that calls my application) ustable and unsupported, and b) I cannot recommend this to my customers since they do not have VS, and neither can I re-distribute editbin.exe. Cheers. Sergey. |
IIRC this specific problem happens in the I/O thread, which we control - can the stack be increased just for that thread? |
The stack size can be specified in the call to _beginthreadex: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/beginthread-beginthreadex |
Do you think it's a good idea to do it? |
In theory, this is plausible. However, the downside of it is potentially running into stack overflow again if the value you pass will not be sufficient. If what is proposed in INSTALL is believed to be a good value - I can send a PR with the fix. |
Well you can decrease the FD_SETSIZE if you're not going to ever need 16384
sockets during runtime. It's the main stack-eater here and the stack
consumption is proportional to 3 X FD_SETSIZE.
Greetings.
…On Feb 14, 2018 14:38, "Sergey Kachanovskiy" ***@***.***> wrote:
In theory, this is plausible. However, the downside of it is potentially
running into stack overflow again if the value you pass will not be
sufficient.
If what is proposed in INSTALL is believed to be a good value - I can send
a PR with the fix.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2344 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/APsYr3tQFnjjlCkGW5MXGrlqVoVDuaVVks5tUuHzgaJpZM4ME_xa>
.
|
I see now that it doesn't make sense I've mentioned the proportion, but
anyway, decreasing FD_SETSIZE will decrease stack consumption. One of the
solutions is to change the code to use dynamic memory allocation but this
can impact performance.
…On Feb 14, 2018 18:25, "BJovke" ***@***.***> wrote:
Well you can decrease the FD_SETSIZE if you're not going to ever need
16384 sockets during runtime. It's the main stack-eater here and the stack
consumption is proportional to 3 X FD_SETSIZE.
Greetings.
On Feb 14, 2018 14:38, "Sergey Kachanovskiy" ***@***.***>
wrote:
> In theory, this is plausible. However, the downside of it is potentially
> running into stack overflow again if the value you pass will not be
> sufficient.
>
> If what is proposed in INSTALL is believed to be a good value - I can
> send a PR with the fix.
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <#2344 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/APsYr3tQFnjjlCkGW5MXGrlqVoVDuaVVks5tUuHzgaJpZM4ME_xa>
> .
>
|
Another option were to build with POLLER=poll, which is, however, broken in 4.2.3, but should be fine in the current master's HEAD (we have only recently added CI tests for that). |
With the latest stable release 4.2.1, I'm having an issue where the creation and deletion of a socket causes a crash in Visual Studio 2012 64 bit builds. I've tried building the library from the provided msvc projects and using CMake and get the same result. This does not happen in later versions of VS that I have tested (2015), and also does not occur in 32 bit builds in VS2012. I've pasted sample code below, the program will crash with an unhandled exception error inside of the libzmq library, in a thread the socket or context creates when using a map on line 77 of select.cpp. I've included sample code that demonstrates this. This occurs when running in both debug and release under x64.
The text was updated successfully, but these errors were encountered: