Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(567)

Issue 670113002: Oilpan: A thread that is not attached to Oilpan shouldn't create a CrossThreadPersistent

Created:
6 years, 2 months ago by haraken
Modified:
6 years, 2 months ago
CC:
blink-reviews, aandrey+blink_chromium.org, sof, eae+blinkwatch, Raymond Toy, blink-reviews-dom_chromium.org, dglazkov+blink, Mikhail, blink-reviews-wtf_chromium.org, mkwst+moarreviews_chromium.org, kouhei+heap_chromium.org, rwlbuis
Project:
blink
Visibility:
Public.

Description

Oilpan: A thread that is not attached to Oilpan shouldn't create a CrossThreadPersistent When the main thread passes a pointer of GarbageCollected object to a WebAudio/HRTFDatabase thread (via postTask), the WebAudio/HRTFDatabase thread creates a CrossThreadPersistent handle for the pointer. However, this is not allowed because the WebAudio/HRTFDatabase thread is not attached to Oilpan. This CL introduces UnretainedPtr and uses it when posting a task to the WebAudio/HRTFDatabase thread. UnretainedPtr is a way to specify that the pointer doesn't need to be protected with a CrossThreadPersistent handle. BUG=425306, 425768 TEST=None. The tests in the crash reports are not minimized.

Patch Set 1 #

Patch Set 2 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+64 lines, -2 lines) Patch
M Source/core/dom/CrossThreadTask.h View 1 chunk +1 line, -0 lines 0 comments Download
M Source/modules/webaudio/ScriptProcessorNode.cpp View 2 chunks +2 lines, -1 line 0 comments Download
M Source/platform/CrossThreadCopier.h View 3 chunks +10 lines, -0 lines 0 comments Download
M Source/platform/audio/HRTFDatabaseLoader.cpp View 2 chunks +2 lines, -1 line 0 comments Download
M Source/platform/heap/Handle.h View 2 chunks +5 lines, -0 lines 0 comments Download
A Source/wtf/UnretainedPtr.h View 1 1 chunk +43 lines, -0 lines 0 comments Download
M Source/wtf/wtf.gypi View 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 10 (1 generated)
haraken
PTAL
6 years, 2 months ago (2014-10-22 07:33:28 UTC) #2
tkent
Why don't we add RootsAccessor::Lock to each function updating Persistent::m_raw?
6 years, 2 months ago (2014-10-22 08:48:08 UTC) #3
Mads Ager (chromium)
On 2014/10/22 08:48:08, tkent wrote: > Why don't we add RootsAccessor::Lock to each function updating ...
6 years, 2 months ago (2014-10-22 09:13:52 UTC) #4
haraken
On 2014/10/22 09:13:52, Mads Ager (chromium) wrote: > On 2014/10/22 08:48:08, tkent wrote: > > ...
6 years, 2 months ago (2014-10-22 10:34:35 UTC) #5
tkent
On 2014/10/22 09:13:52, Mads Ager (chromium) wrote: > On 2014/10/22 08:48:08, tkent wrote: > > ...
6 years, 2 months ago (2014-10-23 01:09:50 UTC) #6
tkent
How to avoid to garbage-collecting |this| after postTask() and before calling the bound function?
6 years, 2 months ago (2014-10-23 01:33:59 UTC) #7
haraken
On 2014/10/23 01:33:59, tkent wrote: > How to avoid to garbage-collecting |this| after postTask() and ...
6 years, 2 months ago (2014-10-23 02:01:26 UTC) #8
tkent
On 2014/10/23 02:01:26, haraken wrote: > On 2014/10/23 01:33:59, tkent wrote: > > How to ...
6 years, 2 months ago (2014-10-23 03:18:43 UTC) #9
haraken
6 years, 2 months ago (2014-10-23 04:01:26 UTC) #10
On 2014/10/23 03:18:43, tkent wrote:
> On 2014/10/23 02:01:26, haraken wrote:
> > On 2014/10/23 01:33:59, tkent wrote:
> > > How to avoid to garbage-collecting |this| after postTask() and before
> calling
> > > the bound function?
> > 
> > That's a responsibility of the caller side to keep |this| alive. (The fact
> that
> > the caller uses "UnretainedPtr" implies that the caller knows that the
pointer
> > is OK to be not retained.)
> > 
> > For example, in case of HRTFDatabaseLoader, HRTFDatabaseLoader is kept alive
> > until the task is processed because the main thread waits for the task
> execution
> > in HRTFDatabaseLoader::waitForLoaderThreadCompletion.
> 
> HRTFDatabaseLoader is not important.  We can add Oilpan support to the data
> loading thread.
> 
> As for AudioScheduledSourceNode, OfflineAudioDestinationNode, and
> ScriptProcessorNode, I'm not sure if we don't need to protect |this|.  I
> remember some of them used to have ref()-deref() and |Persistent<...>
> m_keepAlive|.

Hmm, good point. It's not clear to me either how the |this| pointer is
protected. Also this is not the only place where postTask(..., this) is used in
webaudio/. AudioScheduledSourceNode and OfflineAudioDestinationNode have the
same problem.

Instead of introducing UnretaindPtr, can we probably grab a RootsAccessor::Lock
when creating a CrossThreadPersistent if the thread is not attached to Oilpan?
(It won't cause dead lock.)

Powered by Google App Engine
This is Rietveld 408576698