Skip to content

fix: crash in gin::PerIsolateData::NotifyDisposed when a session is created during quit - #53132

Merged
codebytere merged 1 commit into
42-x-yfrom
bp-52836-42-x-y
Aug 23, 2026
Merged

codebytere merged 1 commit into
42-x-yfrom
bp-52836-42-x-y

Conversation

@codebytere

Copy link
Copy Markdown
Member

Backport of #52836

See that PR for details.

Notes: Fixed a possible main process crash at quit when a session was created from JavaScript that runs during shutdown.

…reated during quit (#52836)

* fix: unregister isolate dispose observers in their destructors

Session, GlobalShortcut and AutoUpdater add themselves as
gin::PerIsolateData::DisposeObserver on construction but only removed
themselves from inside OnBeforeMicrotasksRunnerDispose. An instance
created after that notification has run (for example from a
webContents 'destroyed' handler that fires during exit cleanup) stayed
in the observer list, was finalized together with the cppgc heap inside
v8::Isolate::Dispose(), and the NotifyDisposed() pass that follows then
walked a freed CheckedObserver and hit its CHECK.

Remove the observer in the destructor instead, which covers both the
notified and the late-created case, and make Session::Dispose() key on
browser_context_ rather than keep_alive_ (persistents are already
cleared when finalizers run at heap teardown) so a late session also
drops its DownloadManager observer before the browser context goes away.

* fix: notify isolate dispose observers after CleanedUpAtExit cleanup

Send OnBeforeMicrotasksRunnerDispose from
JavascriptEnvironment::DestroyMicrotasksRunner() once DoCleanup() has
run, instead of from gin's WillDestroyMicrotasksRunner() before it, so
that observers created by JS running during cleanup are notified and
unregister themselves like the rest. This replaces unregistering
Session, GlobalShortcut and AutoUpdater in their destructors.

(cherry picked from commit ceec345)
@codebytere
codebytere requested a review from a team as a code owner August 23, 2026 12:40
@codebytere codebytere added backport This is a backport PR semver/patch backwards-compatible bug fixes 42-x-y labels Aug 23, 2026
@codebytere
codebytere merged commit 277efdf into 42-x-y Aug 23, 2026
90 checks passed
@codebytere
codebytere deleted the bp-52836-42-x-y branch August 23, 2026 14:42
@release-clerk

release-clerk Bot commented Aug 23, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed a possible main process crash at quit when a session was created from JavaScript that runs during shutdown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

42-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants