Skip to content

Fix stack overflow triggered by HTML file with deep <div> nesting - #47830

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
ruthvikkonda:UAF-Mal-HTML
Jul 11, 2025
Merged

webkit-commit-queue merged 1 commit into
WebKit:mainfrom
ruthvikkonda:UAF-Mal-HTML

Conversation

@ruthvikkonda

@ruthvikkonda ruthvikkonda commented Jul 10, 2025 •

Copy link
Copy Markdown
Contributor

915b208

Fix stack overflow triggered by HTML file with deep <div> nesting
https://bugs.webkit.org/show_bug.cgi?id=295722
rdar://152959431

Reviewed by Ryosuke Niwa.

Pop off the HTMLElementStack when we reach max depth to accurately reflect DOM Tree state and mimic current DOM Tree behavior.
New test makes sure that page successfuly loads given large amount of nested divs. The bug previously would cause page to hang.

* LayoutTests/fast/parser/elementstack-nesting-depth-expected.txt: Added.
* LayoutTests/fast/parser/elementstack-nesting-depth.html: Added.
* Source/WebCore/html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::attachLater):

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

49b3647

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe   🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug   🧪 wpe-wk2   🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt   🧪 mac-wk1   🛠 wpe-cairo
✅ 🧪 api-ios ✅ 🧪 mac-wk2   🛠 gtk
✅ 🛠 vision   🧪 mac-AS-debug-wk2   🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress   🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🧪 vision-wk2   🧪 mac-intel-wk2   🛠 playstation
✅ 🛠 tv ✅ 🛠 mac-safer-cpp
✅ 🛠 tv-sim
✅ 🛠 watch
  🛠 watch-sim

@ruthvikkonda ruthvikkonda self-assigned this Jul 10, 2025
@ruthvikkonda ruthvikkonda added the New Bugs Unclassified bugs are placed in this component until the correct component can be determined. label Jul 10, 2025
@ruthvikkonda

Copy link
Copy Markdown
Contributor Author

EWS all green. Ready for review!

@rniwa rniwa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add a test for this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this waitUntilDone is necessary.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use let/const instead.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nor this call to notifyDone.

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jul 11, 2025
@ruthvikkonda ruthvikkonda removed the merging-blocked Applied to prevent a change from being merged label Jul 11, 2025
@rniwa rniwa added the merge-queue Applied to send a pull request to merge-queue label Jul 11, 2025
https://bugs.webkit.org/show_bug.cgi?id=295722
rdar://152959431

Reviewed by Ryosuke Niwa.

Pop off the HTMLElementStack when we reach max depth to accurately reflect DOM Tree state and mimic current DOM Tree behavior.
New test makes sure that page successfuly loads given large amount of nested divs. The bug previously would cause page to hang.

* LayoutTests/fast/parser/elementstack-nesting-depth-expected.txt: Added.
* LayoutTests/fast/parser/elementstack-nesting-depth.html: Added.
* Source/WebCore/html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::attachLater):

Canonical link: https://commits.webkit.org/297288@main
@webkit-commit-queue

Copy link
Copy Markdown
Collaborator

Committed 297288@main (915b208): https://commits.webkit.org/297288@main

Reviewed commits have been landed. Closing PR #47830 and removing active labels.

@webkit-commit-queue
webkit-commit-queue merged commit 915b208 into WebKit:main Jul 11, 2025
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jul 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

New Bugs Unclassified bugs are placed in this component until the correct component can be determined.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants