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: potential async_hooks
crash in NotifyWindowRestore
on Windows
#40576
Conversation
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.
Does it fix the problem if we wrap every Emit
with a node::CallbackScope
? i.e. Put the node::CallbackScope
in CallMethodWithArgs
at event_emitter_caller.cc
.
Sequential emits is rare but it seems impossible to patch all corner cases, for example, the drag-ended
and drop
events of Tray
emit in one tick:
https://github.com/electron/electron/blob/main/shell/browser/ui/tray_icon_cocoa.mm#L303-L309
So I would prefer a generic solution than patching each corner case.
3e4169d
to
b694133
Compare
b694133
to
634e98e
Compare
The failing linux-x64-testing-asan-tests does not seem to be flaky. |
634e98e
to
7a41ee7
Compare
b171538
to
ffb00ae
Compare
error->ToObject(isolate->GetCurrentContext()).ToLocalChecked(), | ||
// Message is also emitted to keep compatibility with old code. | ||
message); | ||
std::vector<v8::Local<v8::Value>> args = { |
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.
autoUpdater
is then only place in the codebase we use gin to emit a proper Error
object. By using gin::EmitEvent
to emit the Error object (thus adding a new CallbackScope
there), and because Errors are handled specially in Node.js, we would otherwise trigger the uncaught exception handler to bypass the try/catch in our autoUpdate specs.
Either we add CallbackScope
s on a case-by-case basis (as i initially tried in this PR) or we account for this edge case. I've chosen to account for this edge case.
3297f3d
to
ba3be2d
Compare
Release Notes Persisted
|
I was unable to backport this PR to "26-x-y" cleanly; |
I have automatically backported this PR to "27-x-y", please check out #41144 |
I have automatically backported this PR to "28-x-y", please check out #41145 |
I have automatically backported this PR to "29-x-y", please check out #41146 |
Description of Change
Closes #40573.
Fixes an issue where an async_hooks crash could occur on Windows only if the user is listening to the
restore
event after minimizing a maximized window and an error occurs in therestore
callback. This was happening after 6b97beb, which created the first instance in our entire codebase where twoEmit
calls were called sequentially. As a result, given they were in the same callbackscope, whennode::RunTimers
ran and an error was occurring in the previous handler, async_hooks would blow up.This fixes that error by putting the first
Emit
in its ownCallbackScope
.Checklist
npm test
passesRelease Notes
Notes: Fixed a potential
async_hooks
crash when listening for therestore
event on Windows after minimizing a maximized BrowserWindow.