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

Issue 568073003: Use weak_ptr in bind call to TraceLog::OnFlushTimeout (Closed)

Created:
6 years, 3 months ago by xunjieli
Modified:
6 years, 3 months ago
Reviewers:
dsinclair, nduca, Xianzhu, mmenke
CC:
chromium-reviews, wfh+watch_chromium.org, dsinclair+watch_chromium.org, erikwright+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Project:
chromium
Visibility:
Public.

Description

Use weak_ptr in bind call to TraceLog::OnFlushTimeout The reason for this change is that OnFlushTimeout callback can run after TraceLog is destroyed for testing, if the message loop that the task gets posted to is not destroyed. (This undesirable effect can currently be seen in https://codereview.chromium.org/468083004/, which causes one of ios_dbg_simulator's net_unittests to crash.) BUG=

Patch Set 1 #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+8 lines, -2 lines) Patch
M base/debug/trace_event_impl.h View 2 chunks +3 lines, -0 lines 0 comments Download
M base/debug/trace_event_impl.cc View 2 chunks +5 lines, -2 lines 1 comment Download

Messages

Total messages: 8 (1 generated)
xunjieli
Hi wangxianzhu, nduca, dsinclair, and mmenke, Please take a look at my CL. Thank you! ...
6 years, 3 months ago (2014-09-12 17:16:08 UTC) #2
mmenke
I defer to others on the best way to fix this issue - not sure ...
6 years, 3 months ago (2014-09-12 17:47:46 UTC) #3
Xianzhu
Unretained(this) should safe because TraceLog is a leaky global object which will be never deleted. ...
6 years, 3 months ago (2014-09-15 16:35:50 UTC) #4
xunjieli
On 2014/09/15 16:35:50, Xianzhu wrote: > Unretained(this) should safe because TraceLog is a leaky global ...
6 years, 3 months ago (2014-09-15 20:53:05 UTC) #5
mmenke
On 2014/09/15 20:53:05, xunjieli1 wrote: > On 2014/09/15 16:35:50, Xianzhu wrote: > > Unretained(this) should ...
6 years, 3 months ago (2014-09-15 20:55:02 UTC) #6
mmenke
On 2014/09/15 20:55:02, mmenke wrote: > On 2014/09/15 20:53:05, xunjieli1 wrote: > > On 2014/09/15 ...
6 years, 3 months ago (2014-09-15 21:01:31 UTC) #7
xunjieli
6 years, 3 months ago (2014-09-15 21:13:04 UTC) #8
On 2014/09/15 21:01:31, mmenke wrote:
> On 2014/09/15 20:55:02, mmenke wrote:
> > On 2014/09/15 20:53:05, xunjieli1 wrote:
> > > On 2014/09/15 16:35:50, Xianzhu wrote:
> > > > Unretained(this) should safe because TraceLog is a leaky global object
> which
> > > > will be never deleted.
> > > > 
> > > > TraceLog::DeleteForTesting() is an exception. It's safe in
base_unittests
> > > > because there is no message loop in the main thread.
> > > > 
> > > > If a test having message loop in the main thread needs to delete
TraceLog,
> > it
> > > > should ensure the message loop is stopped before deleting TraceLog, or
it
> > > should
> > > > not use TraceLog::DeleteForTesting.
> > > 
> > > Thanks Xianzhu. Matt, do you know if there's a way to stop the message
loop
> in
> > > net_unittest from running? (my unit test is at
> > > https://codereview.chromium.org/468083004/patch/250001/260005). Thanks!
> > 
> > There's not - the net/ test fixture sets up the message loop, and it's
shared
> > between all tests.
> 
> So that leaves us with 4 options:
> 
> 1)  Don't delete the TraceLog in the unit test.
> 2)  Refactor the test fixture used by all net unit tests to create a
MessageLoop
> for every test.  This seems like a non-starter.  Even if we did it, if the
> TraceLog is destroyed before the MessageLoop, we have problems, so we can't
> create a MessageLoop in the test fixture at all.
> 3)  Don't run on the net's test fixture's MessageLoop.  Unfortunately, we
can't
> just create a new one to mask the old one.  We'd have to create a new thread,
> and I'm not entirely sure that would actually work - depends on if
> TraceLog::Flush posts a task to the net test fixture's MessageLoop or not.
> 4)  Fix TraceLog::Flush not to depend on being alive as long as the message
loop
> its on.
> 
> If we can 1) working, it's probably the simplest option.

1) seems to work on my local machine. Thanks for the suggestions! I will fix my
other CL.

Powered by Google App Engine
This is Rietveld 408576698