Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a9934374583dc0b3b9c4d5334a602637509119dd
      
https://github.com/WebKit/WebKit/commit/a9934374583dc0b3b9c4d5334a602637509119dd
  Author: Ryosuke Niwa <[email protected]>
  Date:   2026-01-15 (Thu, 15 Jan 2026)

  Changed paths:
    A 
LayoutTests/fast/dom/insert-new-child-to-remove-during-mutation-events-crash-expected.txt
    A 
LayoutTests/fast/dom/insert-new-child-to-remove-during-mutation-events-crash.html
    A 
LayoutTests/fast/dom/insert-new-child-to-remove-during-unload-crash-expected.txt
    A LayoutTests/fast/dom/insert-new-child-to-remove-during-unload-crash.html
    M Source/WebCore/dom/ContainerNode.cpp

  Log Message:
  -----------
  Crash in Node::invalidateNodeListAndCollectionCachesInAncestors via 
ContainerNode::removeAllChildrenWithScriptAssertion
https://bugs.webkit.org/show_bug.cgi?id=305494

Reviewed by Geoffrey Garen and Wenson Hsieh.

The crash was caused by ContainerNode::removeAllChildrenWithScriptAssertion 
sometimes deleting a child node before
node lists of the parent node are invalidated. When node lists' iterator type 
uses a CheckedPtr internally, this
can lead to a crash during the invalidation (because invalidation will try to 
clear that outliving CheckedPtr).

Fixed the bug by re-collecting child nodes of the parent node in 
ContainerNode::removeAllChildrenWithScriptAssertion
if the DOM tree version has changed between when we collected child nodes and 
when mutation events and unload event
handlers are dispatched.

Tests: fast/dom/insert-new-child-to-remove-during-mutation-events-crash.html
       fast/dom/insert-new-child-to-remove-during-unload-crash.html

* 
LayoutTests/fast/dom/insert-new-child-to-remove-during-mutation-events-crash-expected.txt:
 Added.
* 
LayoutTests/fast/dom/insert-new-child-to-remove-during-mutation-events-crash.html:
 Added.
* 
LayoutTests/fast/dom/insert-new-child-to-remove-during-unload-crash-expected.txt:
 Added.
* LayoutTests/fast/dom/insert-new-child-to-remove-during-unload-crash.html: 
Added.
* Source/WebCore/dom/ContainerNode.cpp:
(WebCore::ContainerNode::removeAllChildrenWithScriptAssertion):

Canonical link: https://commits.webkit.org/305651@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to