#53258: fix: use-after-free when event handlers re-enter chooser, protocol stream, webauthn and local AI code
Merged
Created: Aug 28, 2026, 2:18:52 AM
Merged: Aug 28, 2026, 4:58:33 AM
4 comments
Target: main
Description of Change
Fixes six re-entrancy bugs with the same shape: native code emits an event or calls user JS while still holding this or a live iterator, and the handler (legitimately) destroys the owner or mutates the container. All are use-after-free / iterator-invalidation crashes; per-site detail is in each commit.
select-bluetooth-devicecallback invoked synchronously — weak-self check after emit inBluetoothChooser.select-hid-device/hid-device-removedhandler destroys the requestingwebContents— weak-self check inHidChooserController.- Custom protocol stream whose
on()/removeListener()fires listeners synchronously — weak-self checks inNodeStreamLoader::Start, invalidate weak ptrs first in the destructor. select-webauthn-account/-authenticatorlistener calls back then throws — weak-self check after emit.- Cancelling pending local-AI
create()/append()— erase theAbortControllermap entry before callingabort()instead of holding the iterator across it. isolated-world-createdlistener that registers more listeners — iterate a copy of the callback vector.
Regression specs added for all except Bluetooth (needs a real adapter).
Checklist
- PR description included
-
npm testpasses - tests are changed or added
- PR release notes describe the change in a way relevant to app developers, and are capitalized, punctuated, and past tense.
Release Notes
Notes: Fixed crashes when certain app event handlers call back into Electron synchronously.
Backports
43-x-y
PendingWaiting for a manual backport
44-x-y
PendingWaiting for a manual backport
45-x-y
In-flightSemver Impact
Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.
Semantic Versioning helps users understand the impact of updates:
- Major (X.y.z): Breaking changes that may require code modifications
- Minor (x.Y.z): New features that maintain backward compatibility
- Patch (x.y.Z): Bug fixes that don't change the API
- None: Changes that don't affect using facing parts of Electron