#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()afterwebContents.destroy()— useWebContentsObserver::web_contents()instead of a cached pointer; now throwsNo target available.openDevTools()after thesetDevToolsWebContents()target was destroyed — hold it as aWeakPtr, fall back to the built-in DevTools.- Re-initialising a renderer process whose registering
webContentswas destroyed (process sharing) —pending_processes_storesWeakPtr<WebContents>. webContents.destroy()while an HTTP authloginevent is queued — bind aWeakPtrinto the posted task and cancel the auth request if it's gone.hide()/show()on a modal child afterparent.destroy()—NativeWindow::parent_becomesWeakPtr<NativeWindow>.
Each has a regression spec (debugger, webContents ×2, BrowserWindow modal) or crash-case fixture (webcontents-destroy-shared-process).
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 a webContents or parent window is destroyed while other APIs still reference it.
Backports
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