Closed Bug 2080137 Opened 1 month ago Closed 1 month ago

[wpt-sync] Sync PR 63436 - Don't hold a reference to the id attribute across UpdateId()

Categories

(Core :: DOM: Core & HTML, task, P4)

task

Tracking

()

RESOLVED FIXED
160 Branch
Tracking Status
firefox160 --- fixed

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 63436 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/63436
Details from upstream follow.

Mason Freed <masonf@chromium.org> wrote:

Don't hold a reference to the id attribute across UpdateId()

Element::InsertedInto() took a reference into the element's attribute
storage via GetIdAttribute() and passed it to UpdateId(). UpdateId()
notifies id target observers, and those can update style and layout.
For example, a focused \<input list> whose datalist became usable
rebuilds its shadow tree and calls RevealSelection(). If that update
builds a \<use> instance tree that clones the element, cloning
serializes the element's dirty style attribute and appends it to the
attribute storage. When that reallocates the storage, the reference
dangles, and the remaining reads of the id in UpdateId() access freed
memory.

This CL copies the id into a local AtomicString before calling
UpdateId(). RemovedFrom() passes the id to UpdateId() the same way, so
it gets the same change. Recent fixes for similar bugs in
ElementRuleCollector and HTMLAnchorElementBase::NavigateToHyperlink()
used the same approach.

Fixed: 567638392
Change-Id: I1ebac072098091e5dc9d8898f2bced3cf0c3bbcc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8517119
Auto-Submit: Mason Freed \<masonf@chromium.org>
Reviewed-by: David Baron \<dbaron@chromium.org>
Commit-Queue: Mason Freed \<masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1715019}

Component: web-platform-tests → DOM: Core & HTML
Product: Testing → Core
Whiteboard: [wptsync downstream] → [wptsync downstream error]
Whiteboard: [wptsync downstream error] → [wptsync downstream]

CI Results

Ran 11 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI

Total 6 tests

Status Summary

Firefox

OK : 2
PASS: 1[GitHub] 2[Gecko-linux2204-64-wayland-debug, Gecko-linux2204-64-wayland-opt] 3[Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt] 5[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-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]
FAIL: 2

Chrome

PASS: 1

Safari

PASS: 1

Links

Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base

Details

New Tests That Don't Pass

Status: NEW → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 160 Branch
You need to log in before you can comment on or make changes to this bug.