Skip to content

AX: Some places in accessibility traverse through VisiblePositions without checking progress was made, meaning we can loop forever#63268

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
twilco:eng/AX-Some-places-in-accessibility-traverse-through-VisiblePositions-without-checking-progress-was-made-meaning-we-can-loop-forever
Apr 22, 2026
Merged

AX: Some places in accessibility traverse through VisiblePositions without checking progress was made, meaning we can loop forever#63268
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
twilco:eng/AX-Some-places-in-accessibility-traverse-through-VisiblePositions-without-checking-progress-was-made-meaning-we-can-loop-forever

Conversation

@twilco
Copy link
Copy Markdown
Contributor

@twilco twilco commented Apr 21, 2026

57b2f8d

AX: Some places in accessibility traverse through VisiblePositions without checking progress was made, meaning we can loop forever
https://bugs.webkit.org/show_bug.cgi?id=312932
rdar://175280603

Reviewed by Joshua Hoffman.

In 311153@main we fixed three while-loops in AccessibilityObject.cpp where
VisiblePosition::next() or previous() could return the same position, causing
an infinite loop and permanently hanging the main-thread. This change applies
the same defensive pattern to five additional loops that have the same vulnerability:

1. leftLineVisiblePositionRange: previous() loop without progress check
2. rightLineVisiblePositionRange: next() loop without progress check
3. updateAXLineStartForVisiblePosition: while(true) with previous() and no
 stuck-position guard
4. characterOffsetFromVisiblePosition: nextVisuallyDistinctCandidate loop
 with no guard despite comments acknowledging the risk
5. characterOffsetForBounds: bidirectional CharacterOffset iteration with no
 stuck-position check

* LayoutTests/accessibility/left-right-line-range-display-table-in-flex-expected.txt: Added.
* LayoutTests/accessibility/left-right-line-range-display-table-in-flex.html: Added.
* LayoutTests/platform/glib/TestExpectations:
* Source/WebCore/accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::characterOffsetFromVisiblePosition):
(WebCore::AXObjectCache::characterOffsetForBounds):
* Source/WebCore/accessibility/AccessibilityObject.cpp:
(WebCore::updateAXLineStartForVisiblePosition):
(WebCore::AccessibilityObject::leftLineVisiblePositionRange const):
(WebCore::AccessibilityObject::rightLineVisiblePositionRange const):

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

e3ff0ef

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

@twilco twilco self-assigned this Apr 21, 2026
@twilco twilco added the Accessibility For bugs related to accessibility. label Apr 21, 2026
@twilco twilco added the merge-queue Applied to send a pull request to merge-queue label Apr 22, 2026
…thout checking progress was made, meaning we can loop forever

https://bugs.webkit.org/show_bug.cgi?id=312932
rdar://175280603

Reviewed by Joshua Hoffman.

In 311153@main we fixed three while-loops in AccessibilityObject.cpp where
VisiblePosition::next() or previous() could return the same position, causing
an infinite loop and permanently hanging the main-thread. This change applies
the same defensive pattern to five additional loops that have the same vulnerability:

1. leftLineVisiblePositionRange: previous() loop without progress check
2. rightLineVisiblePositionRange: next() loop without progress check
3. updateAXLineStartForVisiblePosition: while(true) with previous() and no
 stuck-position guard
4. characterOffsetFromVisiblePosition: nextVisuallyDistinctCandidate loop
 with no guard despite comments acknowledging the risk
5. characterOffsetForBounds: bidirectional CharacterOffset iteration with no
 stuck-position check

* LayoutTests/accessibility/left-right-line-range-display-table-in-flex-expected.txt: Added.
* LayoutTests/accessibility/left-right-line-range-display-table-in-flex.html: Added.
* LayoutTests/platform/glib/TestExpectations:
* Source/WebCore/accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::characterOffsetFromVisiblePosition):
(WebCore::AXObjectCache::characterOffsetForBounds):
* Source/WebCore/accessibility/AccessibilityObject.cpp:
(WebCore::updateAXLineStartForVisiblePosition):
(WebCore::AccessibilityObject::leftLineVisiblePositionRange const):
(WebCore::AccessibilityObject::rightLineVisiblePositionRange const):

Canonical link: https://commits.webkit.org/311749@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/AX-Some-places-in-accessibility-traverse-through-VisiblePositions-without-checking-progress-was-made-meaning-we-can-loop-forever branch from e3ff0ef to 57b2f8d Compare April 22, 2026 04:15
@webkit-commit-queue
Copy link
Copy Markdown
Collaborator

Committed 311749@main (57b2f8d): https://commits.webkit.org/311749@main

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

@webkit-commit-queue webkit-commit-queue merged commit 57b2f8d into WebKit:main Apr 22, 2026
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Accessibility For bugs related to accessibility.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants