WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
107302
Assert the connectedSubframeCount is consistent and fix over counting
https://bugs.webkit.org/show_bug.cgi?id=107302
Summary
Assert the connectedSubframeCount is consistent and fix over counting
Elliott Sprehn
Reported
2013-01-18 10:31:21 PST
Assert the connectedSubframeCount is consistent in debug
Attachments
Patch
(3.10 KB, patch)
2013-01-18 10:41 PST
,
Elliott Sprehn
no flags
Details
Formatted Diff
Diff
Patch
(3.10 KB, patch)
2013-01-18 10:46 PST
,
Elliott Sprehn
no flags
Details
Formatted Diff
Diff
Patch
(10.75 KB, patch)
2013-01-22 17:08 PST
,
Elliott Sprehn
no flags
Details
Formatted Diff
Diff
Patch
(15.90 KB, patch)
2013-01-23 16:10 PST
,
Elliott Sprehn
no flags
Details
Formatted Diff
Diff
Patch
(13.88 KB, patch)
2013-01-23 16:15 PST
,
Elliott Sprehn
no flags
Details
Formatted Diff
Diff
Patch for landing
(14.12 KB, patch)
2013-01-25 02:16 PST
,
Elliott Sprehn
no flags
Details
Formatted Diff
Diff
Show Obsolete
(5)
View All
Add attachment
proposed patch, testcase, etc.
Elliott Sprehn
Comment 1
2013-01-18 10:41:30 PST
Created
attachment 183501
[details]
Patch
Elliott Sprehn
Comment 2
2013-01-18 10:46:05 PST
Created
attachment 183502
[details]
Patch
Alexey Proskuryakov
Comment 3
2013-01-18 11:16:26 PST
Comment on
attachment 183502
[details]
Patch r=me, although I don't see a reason to not check consistency every time connectedSubframeCount() is called. That would catch errors much closer to when they occur.
Elliott Sprehn
Comment 4
2013-01-18 11:23:49 PST
(In reply to
comment #3
)
> (From update of
attachment 183502
[details]
) > r=me, although I don't see a reason to not check consistency every time connectedSubframeCount() is called. That would catch errors much closer to when they occur.
Because we call that as we walk down the tree in collectFrameOwners() and during tree building, which would mean we'd be walking the subtree, over and over again at every level of the tree making removeChild and parser tree building n^2 in debug builds.
Alexey Proskuryakov
Comment 5
2013-01-18 11:41:37 PST
Sure, but weren't we doing the same before
bug 101821
, without any practical consequences?
Elliott Sprehn
Comment 6
2013-01-18 12:12:18 PST
(In reply to
comment #5
)
> Sure, but weren't we doing the same before
bug 101821
, without any practical consequences?
We only walked the subtree once, it wasn't n^2, and never during tree building in parsing.
Build Bot
Comment 7
2013-01-18 14:12:10 PST
Comment on
attachment 183502
[details]
Patch
Attachment 183502
[details]
did not pass win-ews (win): Output:
http://queues.webkit.org/results/15948532
Elliott Sprehn
Comment 8
2013-01-18 16:18:22 PST
This uncovered a case where we were counting incorrectly due to the way frame tree destruction happens, the incorrect counting is that we over count though, so there's no security problem, we'll just walk the tree looking for loaded frames that are no longer loaded. I'll add a test and reupload.
Elliott Sprehn
Comment 9
2013-01-18 18:20:30 PST
(In reply to
comment #8
)
> This uncovered a case where we were counting incorrectly due to the way frame tree destruction happens, the incorrect counting is that we over count though, so there's no security problem, we'll just walk the tree looking for loaded frames that are no longer loaded. > > I'll add a test and reupload.
Also note that fixing this means we remove a full document traversal during document destruction, so navigating child frames or unloading pages will be faster. ex. window.location = '...'; or frame.contentWindow.location = '...';
Elliott Sprehn
Comment 10
2013-01-22 17:08:15 PST
Created
attachment 184085
[details]
Patch
Elliott Sprehn
Comment 11
2013-01-22 17:18:39 PST
(In reply to
comment #10
)
> Created an attachment (id=184085) [details] > Patch
This is ready for review again. I found no cases of undercounting (security badness) but two cases of overcounting which this fixes.
Elliott Sprehn
Comment 12
2013-01-23 16:10:54 PST
Created
attachment 184335
[details]
Patch
Elliott Sprehn
Comment 13
2013-01-23 16:15:01 PST
Created
attachment 184336
[details]
Patch
Alexey Proskuryakov
Comment 14
2013-01-24 14:58:12 PST
Comment on
attachment 184336
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=184336&action=review
I didn't review particularly deeply, but looks fine. It's a great feeling when adding a check uncovers an actual bug.
> Source/WebCore/dom/ContainerNodeAlgorithms.cpp:125 > +unsigned assertConnectedSubframeCountIsConsistent(Node* node)
I don't get what it means when an "assert" function returns a value. I don't think that it should be named like this in this case.
> Source/WebCore/dom/ContainerNodeAlgorithms.cpp:145 > + // If we overcount it's safe, but not optimal.
It would be helpful to describe in more detail here what is non-optimal. Will we leak? Or will we need to traverse frame tree an extra time somewhere?
Elliott Sprehn
Comment 15
2013-01-25 01:27:57 PST
Comment on
attachment 184336
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=184336&action=review
>> Source/WebCore/dom/ContainerNodeAlgorithms.cpp:125 >> +unsigned assertConnectedSubframeCountIsConsistent(Node* node) > > I don't get what it means when an "assert" function returns a value. I don't think that it should be named like this in this case.
I don't know what else to call it. It recursively asserts as it goes down the tree, so it needs the return value. In a release build all it would do is computeConnectedSubframeCount(), but I don't want anyone to use it outside of debug and calling computeConnectedSubframeCount() inside disconnect() and discarding the value seems pretty weird. Have an idea?
>> Source/WebCore/dom/ContainerNodeAlgorithms.cpp:145 >> + // If we overcount it's safe, but not optimal. > > It would be helpful to describe in more detail here what is non-optimal. Will we leak? Or will we need to traverse frame tree an extra time somewhere?
Done.
Elliott Sprehn
Comment 16
2013-01-25 02:16:30 PST
Created
attachment 184707
[details]
Patch for landing
WebKit Review Bot
Comment 17
2013-01-25 02:49:43 PST
Comment on
attachment 184707
[details]
Patch for landing Clearing flags on attachment: 184707 Committed
r140807
: <
http://trac.webkit.org/changeset/140807
>
WebKit Review Bot
Comment 18
2013-01-25 02:49:48 PST
All reviewed patches have been landed. Closing bug.
Alexey Proskuryakov
Comment 19
2013-01-25 08:31:07 PST
I think that "recursiveCheck..." would be better. Asserts never return values, a "check" function has more leeway.
Elliott Sprehn
Comment 20
2013-01-25 09:44:16 PST
(In reply to
comment #19
)
> I think that "recursiveCheck..." would be better. Asserts never return values, a "check" function has more leeway.
Okay, I'll rename in a followup patch.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug