fix: try clearing InspectableWebContents delegate earlier#49406
Merged
Conversation
deepak1556
reviewed
Jan 15, 2026
deepak1556
left a comment
Member
There was a problem hiding this comment.
Nice!
LGTM with minor change
84c8f39 to
ecfea74
Compare
deepak1556
approved these changes
Jan 15, 2026
dsanders11
approved these changes
Jan 16, 2026
|
Release Notes Persisted
|
This was referenced Jan 16, 2026
Contributor
|
I have automatically backported this PR to "40-x-y", please check out #49422 |
Contributor
|
I have automatically backported this PR to "39-x-y", please check out #49423 |
5 tasks
jkleinsc
pushed a commit
that referenced
this pull request
May 4, 2026
Fix a crash that appears to be a DevTools callback to `DevToolsOpened()` while the WebContents teardown is underway. This PR re-applies 5bd2938 / #49406: the first thing the WebContents destructor does is to clear the IWCV's delegate. That approach was accidentaly circumvented a little by 9f9a5b8 / #50032 which added new code to the beginning of the destructor before clearing the delgate. Sample crash trace: Received signal 11 SEGV_MAPERR 0000000001b8 0 0x55b70ad996b2 base::debug::CollectStackTrace() [../../base/debug/stack_trace_posix.cc:1048:7] 1 0x55b70ad81021 base::debug::StackTrace::StackTrace() [../../base/debug/stack_trace.cc:280:20] 2 0x55b70ad9906f base::debug::(anonymous namespace)::StackDumpSignalHandler() [../../base/debug/stack_trace_posix.cc:483:3] 3 0x7fe851b19520 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x4251f) 4 0x55b70ac8c60d base::internal::WeakReference::IsValid() [../../base/memory/weak_ptr.cc:74:0] 5 0x55b7041101e8 electron::api::WebContents::DevToolsOpened() [../../base/memory/weak_ptr.h:238:32] 6 0x55b7041f5141 electron::InspectableWebContents::LoadCompleted() [../../electron/shell/browser/ui/inspectable_web_contents.cc:632:27] 7 0x55b704033be3 base::RepeatingCallback<>::Run() [../../base/functional/callback.h:343:12] 8 0x55b712272d9a (anonymous namespace)::ParseAndHandle<>() [../../chrome/browser/devtools/devtools_embedder_message_dispatcher.cc:320:13] 9 0x55b712272ec2 base::internal::Invoker<>::Run() [../../base/functional/bind_internal.h:673:12] 10 0x55b712272cf3 base::RepeatingCallback<>::Run() [../../base/functional/callback.h:343:12] 11 0x55b712272c36 DispatcherImpl::Dispatch() [../../chrome/browser/devtools/devtools_embedder_message_dispatcher.cc:389:48] 12 0x55b7041f89c6 electron::InspectableWebContents::HandleMessageFromDevToolsFrontend() [../../electron/shell/browser/ui/inspectable_web_contents.cc:962:33]
jkleinsc
pushed a commit
that referenced
this pull request
May 4, 2026
Fix a crash that appears to be a DevTools callback to `DevToolsOpened()` while the WebContents teardown is underway. This PR re-applies 5bd2938 / #49406: the first thing the WebContents destructor does is to clear the IWCV's delegate. That approach was accidentaly circumvented a little by 9f9a5b8 / #50032 which added new code to the beginning of the destructor before clearing the delgate. Sample crash trace: Received signal 11 SEGV_MAPERR 0000000001b8 0 0x55b70ad996b2 base::debug::CollectStackTrace() [../../base/debug/stack_trace_posix.cc:1048:7] 1 0x55b70ad81021 base::debug::StackTrace::StackTrace() [../../base/debug/stack_trace.cc:280:20] 2 0x55b70ad9906f base::debug::(anonymous namespace)::StackDumpSignalHandler() [../../base/debug/stack_trace_posix.cc:483:3] 3 0x7fe851b19520 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x4251f) 4 0x55b70ac8c60d base::internal::WeakReference::IsValid() [../../base/memory/weak_ptr.cc:74:0] 5 0x55b7041101e8 electron::api::WebContents::DevToolsOpened() [../../base/memory/weak_ptr.h:238:32] 6 0x55b7041f5141 electron::InspectableWebContents::LoadCompleted() [../../electron/shell/browser/ui/inspectable_web_contents.cc:632:27] 7 0x55b704033be3 base::RepeatingCallback<>::Run() [../../base/functional/callback.h:343:12] 8 0x55b712272d9a (anonymous namespace)::ParseAndHandle<>() [../../chrome/browser/devtools/devtools_embedder_message_dispatcher.cc:320:13] 9 0x55b712272ec2 base::internal::Invoker<>::Run() [../../base/functional/bind_internal.h:673:12] 10 0x55b712272cf3 base::RepeatingCallback<>::Run() [../../base/functional/callback.h:343:12] 11 0x55b712272c36 DispatcherImpl::Dispatch() [../../chrome/browser/devtools/devtools_embedder_message_dispatcher.cc:389:48] 12 0x55b7041f89c6 electron::InspectableWebContents::HandleMessageFromDevToolsFrontend() [../../electron/shell/browser/ui/inspectable_web_contents.cc:962:33] Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr <charles@charleskerr.com>
jkleinsc
pushed a commit
that referenced
this pull request
May 5, 2026
Fix a crash that appears to be a DevTools callback to `DevToolsOpened()` while the WebContents teardown is underway. This PR re-applies 5bd2938 / #49406: the first thing the WebContents destructor does is to clear the IWCV's delegate. That approach was accidentaly circumvented a little by 9f9a5b8 / #50032 which added new code to the beginning of the destructor before clearing the delgate. Sample crash trace: Received signal 11 SEGV_MAPERR 0000000001b8 0 0x55b70ad996b2 base::debug::CollectStackTrace() [../../base/debug/stack_trace_posix.cc:1048:7] 1 0x55b70ad81021 base::debug::StackTrace::StackTrace() [../../base/debug/stack_trace.cc:280:20] 2 0x55b70ad9906f base::debug::(anonymous namespace)::StackDumpSignalHandler() [../../base/debug/stack_trace_posix.cc:483:3] 3 0x7fe851b19520 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x4251f) 4 0x55b70ac8c60d base::internal::WeakReference::IsValid() [../../base/memory/weak_ptr.cc:74:0] 5 0x55b7041101e8 electron::api::WebContents::DevToolsOpened() [../../base/memory/weak_ptr.h:238:32] 6 0x55b7041f5141 electron::InspectableWebContents::LoadCompleted() [../../electron/shell/browser/ui/inspectable_web_contents.cc:632:27] 7 0x55b704033be3 base::RepeatingCallback<>::Run() [../../base/functional/callback.h:343:12] 8 0x55b712272d9a (anonymous namespace)::ParseAndHandle<>() [../../chrome/browser/devtools/devtools_embedder_message_dispatcher.cc:320:13] 9 0x55b712272ec2 base::internal::Invoker<>::Run() [../../base/functional/bind_internal.h:673:12] 10 0x55b712272cf3 base::RepeatingCallback<>::Run() [../../base/functional/callback.h:343:12] 11 0x55b712272c36 DispatcherImpl::Dispatch() [../../chrome/browser/devtools/devtools_embedder_message_dispatcher.cc:389:48] 12 0x55b7041f89c6 electron::InspectableWebContents::HandleMessageFromDevToolsFrontend() [../../electron/shell/browser/ui/inspectable_web_contents.cc:962:33] Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr <charles@charleskerr.com>
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
Fixes a crash in
WebContents::DevToolsOpened()that could occur when the DevTools frontend fires itsloadCompletedcallback while the WebContents destructor is running. TheDevToolsEmbedderMessageDispatcherusesbase::Unretainedfor its delegate callbacks, which means it can invokeDevToolsOpened()on a partially-destroyedWebContentswhoseowner_window_WeakPtr has corrupted internal state. This moves theSetDelegate(nullptr)call to the very beginning of the destructor, ensuring no DevTools callbacks can reach us during destruction.Stacktrace
Checklist
npm testpassesRelease Notes
Notes: Fixed a potential race condition crash when opening DevTools.