Repository navigation
fix: WeakPtr crash in WebContents::DevToolsOpened() - #46389
Closed
codebytere wants to merge 1 commit into
Closed
codebytere wants to merge 1 commit into
codebytere wants to merge 1 commit into
Conversation
ckerr
reviewed
Mar 31, 2025
| if (owner_window() && !has_window) | ||
| handle->SetOwnerWindow(devtools, owner_window()); | ||
| if (!has_window) { | ||
| if (const auto* window = owner_window()) |
Member
There was a problem hiding this comment.
I don't understand how this fixes a case where owner_window() returns a dangling pointer?
The non-nullptr test on line 2159 will succeed, so both the old and new version of this function will pass the invalid pointer on to SetOwnerWindow()
Member
That's not how the weakptr contract operates. The current stack traces have limited information to confirm the idea, can we add some crash keys to inDevtoolsOpened to confirm if the weakptr is indeed referring to invalid reference. The keys should capture the output of owner_window_.WasInvalidated, owner_window_.MaybeValid and if owner_window_.get() != raw_ptr_native_window. The raw_ptr_native_window can be captured when the original SetOwnerWindow call for the webcontents happens.
|
Member
Author
this part I can confirm since that showed in the most recent stacktrace i saw for this crash (but now cannot find). |
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
Closes #34042.
Fairly sure what's happening here is that the owner window is getting destroyed but the WeakPtr hasn't been cleared yet, so
owner_window()is returning a dangling pointer, leading to a crash whenSetOwnerWindow()tries to use it.Checklist
npm testpassesRelease Notes
Notes: none