Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1327)

Issue 1204213002: Avoid tail recursion to mitigate stack exhaustion (Closed)

Created:
5 years, 6 months ago by kochi
Modified:
5 years, 6 months ago
Reviewers:
hayato
CC:
blink-reviews
Target Ref:
refs/heads/master
Project:
blink
Visibility:
Public.

Description

Avoid tail recursion to mitigate stack exhaustion This converts tail recursion in findFocusableElementRecursively{Forward,Backward} to loop. These functions still use recursion for nested DOMs. This avoids stack exhaustion in some cases such as a <select> has too many <option>s (<select> and <option> combination is somewhat special because they use user-agent shadow DOM and are handled specially). BUG=445194 TEST=fast/dom/shadow/focus-controller-recursion-crash.html doesn't crash Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=197831

Patch Set 1 : #

Total comments: 12

Patch Set 2 : more recursion to loop conversion #

Patch Set 3 : add a layout test #

Patch Set 4 : fix for comments. #

Total comments: 1

Patch Set 5 : lower the loop threshold from 100000 to 50000 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+83 lines, -49 lines) Patch
A LayoutTests/fast/dom/shadow/focus-controller-recursion-crash.html View 1 2 3 4 1 chunk +22 lines, -0 lines 0 comments Download
A + LayoutTests/fast/dom/shadow/focus-controller-recursion-crash-expected.txt View 1 2 1 chunk +2 lines, -1 line 0 comments Download
M Source/core/page/FocusController.cpp View 1 2 3 1 chunk +59 lines, -48 lines 0 comments Download

Messages

Total messages: 23 (9 generated)
kochi
PTAL
5 years, 6 months ago (2015-06-25 07:13:07 UTC) #4
hayato
I think we can have a layout test for this. https://codereview.chromium.org/1204213002/diff/20001/Source/core/page/FocusController.cpp File Source/core/page/FocusController.cpp (right): https://codereview.chromium.org/1204213002/diff/20001/Source/core/page/FocusController.cpp#newcode382 ...
5 years, 6 months ago (2015-06-25 07:31:02 UTC) #7
kochi
I'm working on adding a layout test. It seems *Backward() still causes stack exhaustion, will ...
5 years, 6 months ago (2015-06-25 07:56:32 UTC) #8
hayato
https://codereview.chromium.org/1204213002/diff/20001/Source/core/page/FocusController.cpp File Source/core/page/FocusController.cpp (right): https://codereview.chromium.org/1204213002/diff/20001/Source/core/page/FocusController.cpp#newcode382 Source/core/page/FocusController.cpp:382: Element* findFocusableElementRecursivelyForward(const FocusNavigationScope& scope, Node* start) On 2015/06/25 07:56:32, ...
5 years, 6 months ago (2015-06-25 08:04:40 UTC) #9
kochi
PTAL Added a layout test. https://codereview.chromium.org/1204213002/diff/20001/Source/core/page/FocusController.cpp File Source/core/page/FocusController.cpp (right): https://codereview.chromium.org/1204213002/diff/20001/Source/core/page/FocusController.cpp#newcode409 Source/core/page/FocusController.cpp:409: return found; On 2015/06/25 ...
5 years, 6 months ago (2015-06-25 08:23:38 UTC) #10
kochi
https://codereview.chromium.org/1204213002/diff/80001/LayoutTests/fast/dom/shadow/focus-controller-recursion-crash.html File LayoutTests/fast/dom/shadow/focus-controller-recursion-crash.html (right): https://codereview.chromium.org/1204213002/diff/80001/LayoutTests/fast/dom/shadow/focus-controller-recursion-crash.html#newcode9 LayoutTests/fast/dom/shadow/focus-controller-recursion-crash.html:9: for (var i = 0; i < 100000; ++i) ...
5 years, 6 months ago (2015-06-25 08:44:05 UTC) #11
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1204213002/80001
5 years, 6 months ago (2015-06-25 09:07:22 UTC) #13
hayato
lgtm
5 years, 6 months ago (2015-06-25 10:36:51 UTC) #14
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
5 years, 6 months ago (2015-06-25 11:28:38 UTC) #16
kochi
On 2015/06/25 08:44:05, Takayoshi Kochi wrote: > https://codereview.chromium.org/1204213002/diff/80001/LayoutTests/fast/dom/shadow/focus-controller-recursion-crash.html > File LayoutTests/fast/dom/shadow/focus-controller-recursion-crash.html (right): > > https://codereview.chromium.org/1204213002/diff/80001/LayoutTests/fast/dom/shadow/focus-controller-recursion-crash.html#newcode9 ...
5 years, 6 months ago (2015-06-25 14:26:36 UTC) #17
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1204213002/100001
5 years, 6 months ago (2015-06-25 15:29:00 UTC) #20
commit-bot: I haz the power
Committed patchset #5 (id:100001) as https://src.chromium.org/viewvc/blink?view=rev&revision=197831
5 years, 6 months ago (2015-06-25 16:40:39 UTC) #21
eae
The new test added by this change is really slow (10+ seconds) and is timing ...
5 years, 6 months ago (2015-06-25 20:05:18 UTC) #22
eae
5 years, 6 months ago (2015-06-25 20:08:11 UTC) #23
Message was sent while issue was closed.
On 2015/06/25 20:05:18, eae wrote:
> The new test added by this change is really slow (10+ seconds) and is timing
out
> on debug bots.

Please fix the test or skip it on debug, marking as slow for debug builds for
now.

Powered by Google App Engine
This is Rietveld 408576698