Bug 106678 - IndexedDB: IDBTransaction should manage lifetime of IDBRequests
Summary: IndexedDB: IDBTransaction should manage lifetime of IDBRequests
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Joshua Bell
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-11 10:34 PST by Joshua Bell
Modified: 2013-01-11 16:18 PST (History)
4 users (show)

See Also:


Attachments
Patch (3.86 KB, patch)
2013-01-11 10:42 PST, Joshua Bell
no flags Details | Formatted Diff | Diff
Patch (4.87 KB, patch)
2013-01-11 14:58 PST, Joshua Bell
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joshua Bell 2013-01-11 10:34:04 PST
IndexedDB: IDBTransaction should manage lifetime of IDBRequests
Comment 1 Joshua Bell 2013-01-11 10:42:24 PST
Created attachment 182368 [details]
Patch
Comment 2 Joshua Bell 2013-01-11 10:45:20 PST
Speculative fix for possible source of crashes. 

In IDBObjectStore.cpp it is assumed that the request is kept alive by the owning transaction, but transactions didn't actually do that.
Comment 3 Alec Flett 2013-01-11 11:31:40 PST
Comment on attachment 182368 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=182368&action=review

> Source/WebCore/Modules/indexeddb/IDBRequest.cpp:82
> +    relaxAdoptionRequirement();

Is this because of the iterator, or removal from the m_requestList? Is there any way to call some of the helper methods like removeFirst or remove(iterator it) ?
Comment 4 Joshua Bell 2013-01-11 11:34:02 PST
(In reply to comment #3)
> (From update of attachment 182368 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=182368&action=review
> 
> > Source/WebCore/Modules/indexeddb/IDBRequest.cpp:82
> > +    relaxAdoptionRequirement();
> 
> Is this because of the iterator, or removal from the m_requestList? Is there any way to call some of the helper methods like removeFirst or remove(iterator it) ?

It on insertion into m_requestList c/o IDBTransaction::registerRequest(), which creates the first RefPtr<> to the request before the IDBRequest's constructor has completed.
Comment 5 Alec Flett 2013-01-11 11:45:40 PST
ah, I see it. LGTM (seems like the proper ownership anyway)
Comment 6 Joshua Bell 2013-01-11 12:22:44 PST
tony@ - can you take a look?
Comment 7 Tony Chang 2013-01-11 14:08:57 PST
Comment on attachment 182368 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=182368&action=review

>>> Source/WebCore/Modules/indexeddb/IDBRequest.cpp:82
>>> +    relaxAdoptionRequirement();
>> 
>> Is this because of the iterator, or removal from the m_requestList? Is there any way to call some of the helper methods like removeFirst or remove(iterator it) ?
> 
> It on insertion into m_requestList c/o IDBTransaction::registerRequest(), which creates the first RefPtr<> to the request before the IDBRequest's constructor has completed.

Rather than using relaxAdoptionRequirement, could we move the call to transaction->registerRequest() into the IDBRequest::create methods?

I think in the long term, we want to remove relaxAdoptionRequirement() from RefCounted.h and it looks like IDB is the only place that uses relaxAdoptionRequirement().
Comment 8 Joshua Bell 2013-01-11 14:58:53 PST
Created attachment 182423 [details]
Patch
Comment 9 Joshua Bell 2013-01-11 15:01:52 PST
(In reply to comment #7)
> Rather than using relaxAdoptionRequirement, could we move the call to transaction->registerRequest() into the IDBRequest::create methods?

Good suggestion - patch updated. (as you noticed...)
 
> I think in the long term, we want to remove relaxAdoptionRequirement() from RefCounted.h and it looks like IDB is the only place that uses relaxAdoptionRequirement().

Once alecflett@'s current refactor is done we can tackle removing the other uses.
Comment 10 WebKit Review Bot 2013-01-11 16:18:12 PST
Comment on attachment 182423 [details]
Patch

Clearing flags on attachment: 182423

Committed r139518: <http://trac.webkit.org/changeset/139518>
Comment 11 WebKit Review Bot 2013-01-11 16:18:16 PST
All reviewed patches have been landed.  Closing bug.