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
Fixed crash on process exit on Windows #10365
Conversation
Awesome, let's get this in asap ⭐ |
atom/app/atom_main.cc
Outdated
// their duties, and when Chromium calls `free` on its buffer, it triggers | ||
// an access violation error. | ||
// We work around this problem by invoking Chromium's `OnThreadExit` in time | ||
// from within the CRT's atexit facility, ensuring the heap functions are still |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is triggering linter error:
atom/app/atom_main.cc:107: Lines should be <= 80 characters long [whitespace/line_length] [2]
8638598
to
756e2ee
Compare
Can we get this into 1.7 as is (there's no branch for that as far as I can tell) while I figure out how to port it to 1.8? Update: Actually I needed to apply the fix only in the release build where Chromium is statically linked. The problem doesn't exist in debug/shared build and the fix doesn't compile in that mode either. |
@alespergl There is a 1.7.x branch here: https://github.com/electron/electron/tree/1-7-x |
756e2ee
to
6e6568b
Compare
6e6568b
to
cfee5ba
Compare
@alespergl thanks for updating the PR. It looks like the Windows 32 bit build is failing:
Linux x64 build fails with the following:
I am going to enable CircleCI on this branch to see if running the Linux x64 build will work there. |
@alespergl All builds are now passing, so I think this is good to go. |
This is a fix for #10188 which was introduced by switching to dynamically linked CRT on Windows. The problem went unnoticed because it is mostly harmless other than recording the app crash in the Windows Event Log. It is desirable to merge this to master and to the 1.7 stream as well.
Description:
Chromium has its own TLS subsystem which supports automatic destruction of thread-local data, and also depends on memory allocation routines provided by the CRT. The problem is that the auto-destruction mechanism uses a hidden feature of the OS loader which calls a callback on thread exit, but only after all loaded DLLs have been detached. Since the CRT is also a DLL, it happens that by the time Chromium's
OnThreadExit
function is called, the heap functions, though still in memory, no longer perform their duties, and when Chromium callsfree
on its buffer, it triggers an access violation error.The workaround is to invoke Chromium's
OnThreadExit
in time from within the CRT's atexit facility, ensuring the heap functions are still active. The second invocation from the OS loader code will be a no-op.