Skip to content

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

Merged
MarshallOfSound merged 1 commit into
43-x-yfrom
trop/43-x-y-bp-fix-crash-in-gin-perisolatedata-notifydisposed-when-a-session-is-created-during-quit-1787002948208
Aug 18, 2026
Merged

MarshallOfSound merged 1 commit into
43-x-yfrom
trop/43-x-y-bp-fix-crash-in-gin-perisolatedata-notifydisposed-when-a-session-is-created-during-quit-1787002948208

Conversation

@trop

@trop trop Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

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.

Co-authored-by: Shelley Vohr <[email protected]>
@trop
trop Bot requested a review from a team as a code owner August 17, 2026 21:42
@trop
trop Bot requested a review from codebytere August 17, 2026 21:42
@trop trop Bot added 43-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes labels Aug 17, 2026
@MarshallOfSound
MarshallOfSound enabled auto-merge (squash) August 18, 2026 00:03
@MarshallOfSound
MarshallOfSound merged commit 3935920 into 43-x-y Aug 18, 2026
96 checks passed
@MarshallOfSound
MarshallOfSound deleted the trop/43-x-y-bp-fix-crash-in-gin-perisolatedata-notifydisposed-when-a-session-is-created-during-quit-1787002948208 branch August 18, 2026 00:03
@release-clerk

release-clerk Bot commented Aug 18, 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

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

Projects

No open projects
Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant