MarshallOfSound

#53257: fix: dangling WebContents/NativeWindow pointers in debugger, devtools, login, modal and process-reuse paths

Merged
Created: Aug 28, 2026, 2:18:45 AM
Merged: Aug 28, 2026, 12:51:32 PM
6 comments
Target: main

Description of Change

Fixes five places where shell/ kept a raw pointer to a content::WebContents / NativeWindow that JS can destroy first. Each was a main-process use-after-free reachable from public API; details in the individual commits.

  • webContents.debugger.attach() after webContents.destroy() — use WebContentsObserver::web_contents() instead of a cached pointer; now throws No target available.
  • openDevTools() after the setDevToolsWebContents() target was destroyed — hold it as a WeakPtr, fall back to the built-in DevTools.
  • Re-initialising a renderer process whose registering webContents was destroyed (process sharing) — pending_processes_ stores WeakPtr<WebContents>.
  • webContents.destroy() while an HTTP auth login event is queued — bind a WeakPtr into the posted task and cancel the auth request if it's gone.
  • hide()/show() on a modal child after parent.destroy()NativeWindow::parent_ becomes WeakPtr<NativeWindow>.

Each has a regression spec (debugger, webContents ×2, BrowserWindow modal) or crash-case fixture (webcontents-destroy-shared-process).

Checklist

Release Notes

Notes: Fixed crashes when a webContents or parent window is destroyed while other APIs still reference it.

Backports

43-x-y
Merged
PR Number
#53288
Merged At
Aug 28, 2026, 6:46:47 PM
Released In
Not yet
Release Date
Not yet
44-x-y
Merged
PR Number
#53287
Merged At
Aug 28, 2026, 6:48:41 PM
Released In
Not yet
Release Date
Not yet
45-x-y
Merged
PR Number
#53281
Merged At
Aug 28, 2026, 5:13:06 PM
Released In
Not yet
Release Date
Not yet

Semver 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