[wpt-sync] Sync PR 62716 - Maintain the kIsInShadowTree node flag in TreeScopeAdopter.
Categories
(Core :: Layout: Positioned, task, P4)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox158 | --- | fixed |
People
(Reporter: wpt-sync, Unassigned)
References
()
Details
(Whiteboard: [wptsync downstream])
Sync web-platform-tests PR 62716 into mozilla-central (this bug is closed when the sync is complete).
PR: https://github.com/web-platform-tests/wpt/pull/62716
Details from upstream follow.
David Baron <dbaron@chromium.org> wrote:
Maintain the kIsInShadowTree node flag in TreeScopeAdopter.
During node insertion and removal operations we traverse the
inserted/removed subtree and call InsertedInto or RemovedFrom on the
nodes in the subtree. During an InsertedInto or RemovedFrom call on a
node in the subtree, other nodes in the subtree are in a "bad" state
where they have been inserted/removed, but InsertedInto/RemovedFrom has
not yet been called.This change keeps the kIsInShadowTree flag more consistent with the tree
scope, so that it is no longer one of the things that can be "bad" in
that bad state, and means that during a traversal of Node::InsertedInto
or Node::RemovedFrom calls, the kIsInShadowTree flag has already been
updated for all of the nodes being traversed.Right now RemovedFrom can trigger other traversals via the following stack:
RemovedFrom () at element.cc:4652
RemoveFromTopLayerImmediately () at document.cc:8758
ElementRemovedFromTopLayer () at display_lock_document_state.cc:247
MarkAncestorContextsHaveTopLayerElement () at display_lock_document_state.cc:257
ParentElement () at flat_tree_traversal.h:219
Parent () at flat_tree_traversal.h:213
TraverseParent () at flat_tree_traversal.cc:180
AssignedNodes () at html_slot_element.cc:87
GetSlotAssignment () at shadow_root.h:120
In this stack, Node::RemovedFrom calls RemoveFromTopLayerImmediately,
which does a fresh set of flat tree traversals from all elements that
remain in the top layer. Those traversals can reach elements that are
still to come in the Node::RemovedFrom traversal, and that thus without
this change will have their kIsInShadowTreeFlag set incorrectly, which
can lead to a null dereference when HTMLSlotElement::AssignedNodes calls
GetSlotAssignment() on the null result of ContainingShadowRoot() because
SupportsAssignment() checked the (stale) flag and returned true.Fixed: 550975373
Change-Id: Id9579dd24a7cbe85ce0f0b3d8cdb9e4267e95e73Reviewed-on: https://chromium-review.googlesource.com/8389929
WPT-Export-Revision: 0b2880a75a0c4259407dd2194b29c00b79c8a4c1
| Assignee | ||
Updated•2 months ago
|
| Assignee | ||
Comment 1•2 months ago
|
||
Pushed to try (stability) https://treeherder.mozilla.org/jobs?repo=try&landoInstance=lando-prod-2025&landoCommitID=92301
| Assignee | ||
Comment 2•2 months ago
|
||
CI Results
Ran 11 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI
Total 13 tests
Status Summary
Firefox
PASS : 2[GitHub] 13[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview, Gecko-linux2204-64-wayland-debug, Gecko-linux2204-64-wayland-opt, Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]
Chrome
CRASH: 2
Safari
PASS : 2
Links
Comment 4•2 months ago
|
||
| bugherder | ||
Description
•