Skip to content

Cherry-pick(s) dcc59c29504a. rdar://191059662 - #78736

Open
webkit-opensource-integration wants to merge 1 commit into
mainfrom
integration/conflict/dcc59c29504a_dcc59c29504a_main
Open

webkit-opensource-integration wants to merge 1 commit into
mainfrom
integration/conflict/dcc59c29504a_dcc59c29504a_main

Conversation

@webkit-opensource-integration

@webkit-opensource-integration webkit-opensource-integration commented Oct 29, 2026 •

Copy link
Copy Markdown

Integration has hit a merge conflict while cherry-picking rdar://191059662 to main. [dcc59c2] caused a merge conflict.

Prevent reentrant script during CSSFontFace client notification
rdar://186024085

Reviewed by Chris Dumez.

Resolving a promise with an object performs a synchronous get(resolution, "then").
FontFace.loaded and FontFaceSet's promises resolve with such an object from inside
CSSFontFace::setStatus's client notification, so an author then getter can run
synchronous script there and mutate font data that a suspended caller is still
using. This is the shared cause behind rdar://182680798, rdar://183298366, and
rdar://185867407 in addition to this radar, on both the main thread and workers.

DeferredPromise::callFunction already deferred a resolution on the main thread
when ScriptDisallowedScope::isScriptAllowedInMainThread() was false, but nothing
in font code entered that scope. Workers had no equivalent at all. The check
returns true for any thread that is not the main one, regardless of any scope.
FontFace and FontFaceSet are exposed to workers, so CSSFontFace::setStatus and
its client notification run on the worker thread that owns them.

* Source/WebCore/css/CSSFontFace.cpp:
(WebCore::iterateClients):
* Source/WebCore/dom/ContainerNode.cpp:
* Source/WebCore/dom/ScriptDisallowedScope.h:
(WebCore::ScriptDisallowedScope::ScriptDisallowedScope):
(WebCore::ScriptDisallowedScope::~ScriptDisallowedScope):
(WebCore::ScriptDisallowedScope::isScriptAllowedInCurrentThread):
* Source/WebCore/bindings/js/JSDOMPromiseDeferred.cpp:
(WebCore::DeferredPromise::callFunction):
* LayoutTests/sar3/fast/text/font-face/font-cascade-width-glyph-geometry-cache-reentrancy-crash.html: Added.
* LayoutTests/sar3/fast/text/font-face/font-cascade-width-glyph-geometry-cache-reentrancy-crash-expected.txt: Added.
* LayoutTests/sar3/fast/text/font-face/font-face-loaded-resolution-deferred-in-worker.html: Added.
* LayoutTests/sar3/fast/text/font-face/font-face-loaded-resolution-deferred-in-worker-expected.txt: Added.

Originally-landed-as: 316606.620@safari-7625-branch (dcc59c29504a). rdar://191059662


ℹ️ Info

RC_REMOVE_SEC_ACCEL_* guards were removed with unifdef before cherry-picking, keeping only the code built when the macro is not defined.

49a7183

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ❌ 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-cmake-debug loading 🧪 wpe-wk2 ❌ 🧪 win-tests
✅ 🧪 webkitperl loading 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
⏳ 🧪 ios-wk2-wpt ⏳ 🧪 api-mac-cmake-debug
⏳ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk3-gcc
✅ 🛠 ios-safer-cpp ⏳ 🧪 mac-cmake-debug-wk2 ✅ 🛠 gtk
✅ 🛠 vision ✅ 🧪 mac-wk2-stress loading 🧪 gtk-wk2
✅ 🛠 vision-sim ⏳ 🧪 mac-intel-wk2 ✅ 🧪 api-gtk
✅ 🧪 vision-wk2 ✅ 🛠 mac-safer-cpp ⏳ 🛠 playstation
✅ 🛠 tv ✅ 🧪 mac-site-isolation
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

rdar://186024085

Reviewed by Chris Dumez.

Resolving a promise with an object performs a synchronous get(resolution, "then").
FontFace.loaded and FontFaceSet's promises resolve with such an object from inside
CSSFontFace::setStatus's client notification, so an author then getter can run
synchronous script there and mutate font data that a suspended caller is still
using. This is the shared cause behind rdar://182680798, rdar://183298366, and
rdar://185867407 in addition to this radar, on both the main thread and workers.

DeferredPromise::callFunction already deferred a resolution on the main thread
when ScriptDisallowedScope::isScriptAllowedInMainThread() was false, but nothing
in font code entered that scope. Workers had no equivalent at all. The check
returns true for any thread that is not the main one, regardless of any scope.
FontFace and FontFaceSet are exposed to workers, so CSSFontFace::setStatus and
its client notification run on the worker thread that owns them.

* Source/WebCore/css/CSSFontFace.cpp:
(WebCore::iterateClients):
* Source/WebCore/dom/ContainerNode.cpp:
* Source/WebCore/dom/ScriptDisallowedScope.h:
(WebCore::ScriptDisallowedScope::ScriptDisallowedScope):
(WebCore::ScriptDisallowedScope::~ScriptDisallowedScope):
(WebCore::ScriptDisallowedScope::isScriptAllowedInCurrentThread):
* Source/WebCore/bindings/js/JSDOMPromiseDeferred.cpp:
(WebCore::DeferredPromise::callFunction):
* LayoutTests/sar3/fast/text/font-face/font-cascade-width-glyph-geometry-cache-reentrancy-crash.html: Added.
* LayoutTests/sar3/fast/text/font-face/font-cascade-width-glyph-geometry-cache-reentrancy-crash-expected.txt: Added.
* LayoutTests/sar3/fast/text/font-face/font-face-loaded-resolution-deferred-in-worker.html: Added.
* LayoutTests/sar3/fast/text/font-face/font-face-loaded-resolution-deferred-in-worker-expected.txt: Added.

Originally-landed-as: 316606.620@safari-7625-branch (dcc59c2). rdar://191059662
@webkit-opensource-integration

Copy link
Copy Markdown
Author

Integration performed the following cherry-picks: dcc59c2 for rdar://191059662. dcc59c2 caused a merge conflict.

@webkit-opensource-integration

Copy link
Copy Markdown
Author

At the time this pull request was created the following files were in conflict and need to be resolved:

  • LayoutTests/fast/css/font-cascade-width-glyph-geometry-cache-reentrancy-crash-expected.txt — added on the target branch and left unmerged
  • LayoutTests/fast/css/font-cascade-width-glyph-geometry-cache-reentrancy-crash.html — added on the target branch and left unmerged
  • LayoutTests/fast/css/font-face-loaded-resolution-deferred-in-worker-expected.txt — added on the target branch and left unmerged
  • LayoutTests/fast/css/font-face-loaded-resolution-deferred-in-worker.html — added on the target branch and left unmerged

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merging-blocked Applied to prevent a change from being merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants