Bug 40968 - Make PendingScript hold a CachedResourceClient open for its lifetime
Summary: Make PendingScript hold a CachedResourceClient open for its lifetime
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other OS X 10.5
: P2 Normal
Assignee: Tony Gentilcore
URL:
Keywords:
Depends on:
Blocks: 40934
  Show dependency treegraph
 
Reported: 2010-06-21 22:46 PDT by Tony Gentilcore
Modified: 2010-06-25 22:27 PDT (History)
5 users (show)

See Also:


Attachments
Patch (14.21 KB, patch)
2010-06-21 22:53 PDT, Tony Gentilcore
no flags Details | Formatted Diff | Diff
Patch (14.21 KB, patch)
2010-06-22 08:30 PDT, Tony Gentilcore
no flags Details | Formatted Diff | Diff
Rollback (14.44 KB, patch)
2010-06-22 18:24 PDT, Tony Gentilcore
no flags Details | Formatted Diff | Diff
Patch (14.48 KB, patch)
2010-06-24 20:56 PDT, Tony Gentilcore
no flags Details | Formatted Diff | Diff
Patch for landing (14.48 KB, patch)
2010-06-24 21:04 PDT, Tony Gentilcore
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tony Gentilcore 2010-06-21 22:46:53 PDT
Make PendingScript hold a CachedResourceClient open for its lifetime
Comment 1 Tony Gentilcore 2010-06-21 22:53:30 PDT
Created attachment 59340 [details]
Patch
Comment 2 Eric Seidel (no email) 2010-06-21 22:56:42 PDT
Comment on attachment 59340 [details]
Patch

WebCore/html/HTML5ScriptRunner.h:31
 +  #include "CachedScript.h"
Would be better to do this in the .cpp.
Comment 3 Eric Seidel (no email) 2010-06-21 23:10:58 PDT
Comment on attachment 59340 [details]
Patch

WebCore/html/HTML5ScriptRunner.cpp:57
 +      if (m_parsingBlockingScript.cachedScript() && m_parsingBlockingScript.watchingForLoad)
I don't thin we should bother moving watchingForLoad() back to being a direct-access member.  I suspect that PendingScript is only going to be moving more and more towards class-ness.

I'm also not sure it maters. :)

Move the implementation stuff into the cpp, and then I think this is good to go.
Comment 4 Tony Gentilcore 2010-06-22 08:30:29 PDT
Created attachment 59370 [details]
Patch
Comment 5 Eric Seidel (no email) 2010-06-22 11:51:59 PDT
Comment on attachment 59370 [details]
Patch

LGTM!  Note, no need for argument names when they don't add anything ( 78         void setCachedScript(CachedScript* cachedScript);
)

No need to change it here though.  We really need you to have commit-bit so nits are easier to fix on landing. :)
Comment 6 Tony Gentilcore 2010-06-22 11:53:52 PDT
(In reply to comment #5)
> (From update of attachment 59370 [details])
> LGTM!  Note, no need for argument names when they don't add anything ( 78         void setCachedScript(CachedScript* cachedScript);
> )

I think this is the second time I've done that. So I'll put together a style-nit patch to fix those problems in WebCore/html/HTML5*

> 
> No need to change it here though.  We really need you to have commit-bit so nits are easier to fix on landing. :)

Paperwork is in the mail :)
Comment 7 Adam Barth 2010-06-22 16:47:06 PDT
Committed r61638: <http://trac.webkit.org/changeset/61638>
Comment 8 WebKit Review Bot 2010-06-22 17:36:03 PDT
http://trac.webkit.org/changeset/61638 might have broken Qt Linux Release
The following changes are on the blame list:
http://trac.webkit.org/changeset/61640
http://trac.webkit.org/changeset/61638
http://trac.webkit.org/changeset/61639
Comment 9 Eric Seidel (no email) 2010-06-22 17:50:03 PDT
I think this caused 2 test cases to crash.
Comment 10 Tony Gentilcore 2010-06-22 18:24:35 PDT
Created attachment 59455 [details]
Rollback
Comment 11 Tony Gentilcore 2010-06-22 18:26:29 PDT
Rollback tested by building and running http/tests/security/frame-loading-via-document-write.html on Windows.
Comment 12 Tony Gentilcore 2010-06-22 18:30:50 PDT
reopening for rollback
Comment 13 Eric Seidel (no email) 2010-06-22 18:36:08 PDT
Comment on attachment 59455 [details]
Rollback

ChangeLogs are append-only.
Comment 14 Eric Seidel (no email) 2010-06-22 18:41:57 PDT
Committed r61646: <http://trac.webkit.org/changeset/61646>
Comment 15 Eric Seidel (no email) 2010-06-22 18:42:28 PDT
Rolled out in above commit.
Comment 16 Adam Barth 2010-06-23 02:23:26 PDT
Sorry Tony.  I just renamed everything under the sun.  :(
Comment 17 Mark Rowe (bdash) 2010-06-23 21:57:06 PDT
We happened to pick up r61638 in one of our internal builds before we noticed that it was rolled out.  It was causing crashes in Safari too.  I spent some time debugging and tracked it down to PendingScript’s lack of a copy constructor and assignment operator.  The fact that HTMLScriptRunner::executePendingScript clears m_parsingBlockingScript by doing:

    m_parsingBlockingScript = PendingScript();

combined with the fact that PendingScript::setCachedScript unregisters / registers the PendingScript as a client of the CachedScript results in PendingScript instances sticking around as clients of CachedScripts even after they’re deleted, since they never have an opportunity to unregister themselves as a client.

A trivial fix for that would be to add a clear method to PendingScript that uses setCachedScript(0) to clear the m_cachedScript member and just zeroes the other members, and then to adopt .clear() in place of the assignment operator above.  Updating the class to inherit from Noncopyable will also avoid this mistake from being repeated.

Hope that helps!
Comment 18 Adam Barth 2010-06-23 22:02:45 PDT
Thanks Mark.  That's very helpful.
Comment 19 Tony Gentilcore 2010-06-24 20:56:09 PDT
Created attachment 59722 [details]
Patch
Comment 20 WebKit Review Bot 2010-06-24 21:01:38 PDT
Attachment 59722 [details] did not pass style-queue:

Failed to run "['WebKitTools/Scripts/check-webkit-style', '--no-squash']" exit_code: 1
WebCore/ChangeLog:13:  Line contains tab character.  [whitespace/tab] [5]
Total errors found: 1 in 5 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 21 Eric Seidel (no email) 2010-06-24 21:02:04 PDT
Comment on attachment 59722 [details]
Patch

WebCore/ChangeLog:14
 +          No new tests because making a CachedResource purse itself is not
purge

LGTM.
Comment 22 Tony Gentilcore 2010-06-24 21:04:04 PDT
Created attachment 59725 [details]
Patch for landing
Comment 23 Alexey Proskuryakov 2010-06-25 10:10:33 PDT
Is the crash also untestable, or only the original fix isn't?

We really need better testing hooks for WebCore resource cache. It's such a large and important area of code, and almost untested!

Can a layoutTestController method be added that would make this testable?
Comment 24 Tony Gentilcore 2010-06-25 10:44:12 PDT
(In reply to comment #23)
> Is the crash also untestable, or only the original fix isn't?

The crash showed up on two layout tests, so it is tested.

This was landed without the CQ, the crashes showed up, and it was rolled back just a few revisions later. It was kind of a strange fluke that the nightly was cut in between the landing and the rollback.

> 
> We really need better testing hooks for WebCore resource cache. It's such a large and important area of code, and almost untested!

Totally agreed. It is scary.

> 
> Can a layoutTestController method be added that would make this testable?

Good idea. I think a method that purges all purgeable buffers would be perfect.
Comment 25 Eric Seidel (no email) 2010-06-25 11:27:39 PDT
(In reply to comment #24)
> > Can a layoutTestController method be added that would make this testable?
> 
> Good idea. I think a method that purges all purgeable buffers would be perfect.

Woh, that would be useful!  We should at least file a bug for that.
Comment 26 Tony Gentilcore 2010-06-25 11:32:24 PDT
(In reply to comment #25)
> (In reply to comment #24)
> > > Can a layoutTestController method be added that would make this testable?
> > 
> > Good idea. I think a method that purges all purgeable buffers would be perfect.
> 
> Woh, that would be useful!  We should at least file a bug for that.

https://bugs.webkit.org/show_bug.cgi?id=41219
Comment 27 WebKit Commit Bot 2010-06-25 22:27:49 PDT
Comment on attachment 59725 [details]
Patch for landing

Clearing flags on attachment: 59725

Committed r61940: <http://trac.webkit.org/changeset/61940>
Comment 28 WebKit Commit Bot 2010-06-25 22:27:56 PDT
All reviewed patches have been landed.  Closing bug.