Bug 30033 - [chromium] DateExtension has reliability bot crashes
Summary: [chromium] DateExtension has reliability bot crashes
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC All
: P2 Normal
Assignee: Adam Barth
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-02 16:23 PDT by John Abd-El-Malek
Modified: 2009-10-05 22:28 PDT (History)
3 users (show)

See Also:


Attachments
Proposed patch (6.21 KB, patch)
2009-10-02 16:32 PDT, John Abd-El-Malek
abarth: review-
Details | Formatted Diff | Diff
Updated per review comments (7.56 KB, patch)
2009-10-05 10:51 PDT, John Abd-El-Malek
abarth: review-
Details | Formatted Diff | Diff
Updated patch (7.56 KB, patch)
2009-10-05 21:38 PDT, John Abd-El-Malek
abarth: review+
commit-queue: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Abd-El-Malek 2009-10-02 16:23:56 PDT
See http://code.google.com/p/chromium/issues/detail?id=23043

Mads helped me track this down, looks like the weak persistent handle approach is problematic since the JS function has no one else grabbing a reference to it, so it can be destroyed during GC when the other JS enableSleepDetection function pointers are being called.  This leads to problem since during iteration the vector can change.

A simpler solution is to add the function pointer as a hidden value on the Date constructor.  This patch achieves that.
Comment 1 John Abd-El-Malek 2009-10-02 16:32:18 PDT
Created attachment 40557 [details]
Proposed patch
Comment 2 Adam Barth 2009-10-05 10:11:45 PDT
Comment on attachment 40557 [details]
Proposed patch

Please use V8HiddenPropertyName to avoid hidden property name collisions.
Comment 3 Adam Barth 2009-10-05 10:44:49 PDT
Also, we need a test.  :)
Comment 4 John Abd-El-Malek 2009-10-05 10:51:22 PDT
Created attachment 40642 [details]
Updated per review comments
Comment 5 John Abd-El-Malek 2009-10-05 10:55:20 PDT
This code is already tested by slow_unload_handler.html.  The crash happened on the reliability bot sporadically, and I couldn't repro it.
Comment 6 Adam Barth 2009-10-05 10:57:53 PDT
Comment on attachment 40642 [details]
Updated per review comments

We should add a test for the crash.

+ v8::Local<v8::Value> result = V8Proxy::retrieve()->evaluate(WebCore::ScriptSourceCode("Date"), 0);

This seems overly complicated.  Why not just get the "Date" property of the context's global object?

Other than those two issue, this looks reasonable.
Comment 7 Adam Barth 2009-10-05 10:58:36 PDT
(In reply to comment #5)
> This code is already tested by slow_unload_handler.html.  The crash happened on
> the reliability bot sporadically, and I couldn't repro it.

Ah, didn't see this comment before.  Have you tried forcing a GC while running the test?
Comment 8 John Abd-El-Malek 2009-10-05 11:01:18 PDT
(In reply to comment #6)
> (From update of attachment 40642 [details])
> We should add a test for the crash.

This wasn't a reproducible crash.  I'm open to suggestions on how this crash can be reproduced.

> 
> + v8::Local<v8::Value> result =
> V8Proxy::retrieve()->evaluate(WebCore::ScriptSourceCode("Date"), 0);
> 
> This seems overly complicated.  Why not just get the "Date" property of the
> context's global object?

Mads had suggested this.  It's useful in case the page replaced the Date object, in which case we don't want to override getTime since they could have changed its functionality (i.e. added extra parameters).

> 
> Other than those two issue, this looks reasonable.
Comment 9 Adam Barth 2009-10-05 13:10:30 PDT
(In reply to comment #8)
> This wasn't a reproducible crash.  I'm open to suggestions on how this crash
> can be reproduced.

Did you try running GC explicitly at an opportune moment?  I think there's a function to force GC around somewhere in LayoutTests.

> > + v8::Local<v8::Value> result =
> > V8Proxy::retrieve()->evaluate(WebCore::ScriptSourceCode("Date"), 0);
> > 
> > This seems overly complicated.  Why not just get the "Date" property of the
> > context's global object?
> 
> Mads had suggested this.  It's useful in case the page replaced the Date
> object, in which case we don't want to override getTime since they could have
> changed its functionality (i.e. added extra parameters).

How does this solve that problem?  Won't evaling "Date" just give you the modified object?
Comment 10 John Abd-El-Malek 2009-10-05 13:31:30 PDT
(In reply to comment #9)
> (In reply to comment #8)
> > This wasn't a reproducible crash.  I'm open to suggestions on how this crash
> > can be reproduced.
> 
> Did you try running GC explicitly at an opportune moment?  I think there's a
> function to force GC around somewhere in LayoutTests.

Yeah I tried that, but the crash only happens if GC happens during the call to the enableSleepDetection function that's in the closure.  Trying to simulate gc in the unload handlers themselves doesn't trigger this.

> 
> > > + v8::Local<v8::Value> result =
> > > V8Proxy::retrieve()->evaluate(WebCore::ScriptSourceCode("Date"), 0);
> > > 
> > > This seems overly complicated.  Why not just get the "Date" property of the
> > > context's global object?
> > 
> > Mads had suggested this.  It's useful in case the page replaced the Date
> > object, in which case we don't want to override getTime since they could have
> > changed its functionality (i.e. added extra parameters).
> 
> How does this solve that problem?  Won't evaling "Date" just give you the
> modified object?

It prevents this problem because the modified "Date" object won't have the hidden property on it, so the code will early return.
Comment 11 Adam Barth 2009-10-05 15:27:44 PDT
> > > > This seems overly complicated.  Why not just get the "Date" property of the
> > > > context's global object?
> 
> It prevents this problem because the modified "Date" object won't have the
> hidden property on it, so the code will early return.

Oh, I'm just saying that you replace the "eval the string Date" code with "get the Date property of the global object".  I agree that you should continue to store the hidden property on the Date object itself.
Comment 12 John Abd-El-Malek 2009-10-05 21:38:17 PDT
Created attachment 40684 [details]
Updated patch
Comment 13 Adam Barth 2009-10-05 21:45:57 PDT
Comment on attachment 40684 [details]
Updated patch

Thanks John.

Normally we check the result of V8Proxy::retrieve()->context() to see if the context is empty (e.g., because JavaScript is disabled).  I don't think we can get into that situation here, however.
Comment 14 WebKit Commit Bot 2009-10-05 21:48:30 PDT
Comment on attachment 40684 [details]
Updated patch

Rejecting patch 40684 from commit-queue.

Patch https://bugs.webkit.org/attachment.cgi?id=40684 from bug 30033 failed to download and apply.
Comment 15 Adam Barth 2009-10-05 21:49:34 PDT
I'll land this by hand.
Comment 16 Adam Barth 2009-10-05 21:55:23 PDT
Committed r49148: <http://trac.webkit.org/changeset/49148>
Comment 17 John Abd-El-Malek 2009-10-05 22:23:51 PDT
(In reply to comment #16)
> Committed r49148: <http://trac.webkit.org/changeset/49148>

Thanks, btw for future reference I'm a committer so I don't need to burden anyone anymore.
Comment 18 Adam Barth 2009-10-05 22:28:24 PDT
> Thanks, btw for future reference I'm a committer so I don't need to burden
> anyone anymore.

Ah, I knew that, but forgot.  You might want to add yourself to this page:

http://trac.webkit.org/wiki/WebKit%20Team

In any case, I knew what the merge conflict was because I r+ed the conflicting change, so it was easy for me to fix.