Closed Bug 2072339 Opened 2 months ago Closed 2 months ago

[wpt-sync] Sync PR 62716 - Maintain the kIsInShadowTree node flag in TreeScopeAdopter.

Categories

(Core :: Layout: Positioned, task, P4)

task

Tracking

()

RESOLVED FIXED
158 Branch
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: Id9579dd24a7cbe85ce0f0b3d8cdb9e4267e95e73

Reviewed-on: https://chromium-review.googlesource.com/8389929
WPT-Export-Revision: 0b2880a75a0c4259407dd2194b29c00b79c8a4c1

Component: web-platform-tests → Layout: Positioned
Product: Testing → Core

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

Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base

Pushed by wptsync@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/98b3ae25a5c0 https://hg.mozilla.org/integration/autoland/rev/fddf8db2cf83 [wpt PR 62716] - Maintain the kIsInShadowTree node flag in TreeScopeAdopter., a=testonly
Status: NEW → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 158 Branch
You need to log in before you can comment on or make changes to this bug.