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

Issue 13023: Found a bug in the BaseTimer (used by OneShotTimer).... (Closed)

Created:
12 years ago by Mike Belshe
Modified:
9 years, 5 months ago
CC:
chromium-reviews_googlegroups.com
Visibility:
Public.

Description

Found a bug in the BaseTimer (used by OneShotTimer). If you have a OneShotTimer pending, and you destroy your message loop, the cleanup of the timer will use memory which was already freed by the MessageLoop. When the MessageLoop shuts down, it deletes pending tasks. BaseTimer did not provide a virtual destructor to cleanup its "base". Thus, when the actual OneShotTimer cleaned up, it would use deleted memory. This manifested for me when I had accidentally had cleanup of a oneshottimer occurring through the Singleton, which occurs AtExit, after the messageloop is already gone. Created a unit test for this, which does trip the assert due to heap corruption. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=6190

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+48 lines, -6 lines) Patch
M base/timer.h View 1 chunk +27 lines, -6 lines 1 comment Download
M base/timer_unittest.cc View 1 chunk +21 lines, -0 lines 0 comments Download

Messages

Total messages: 5 (0 generated)
Mike Belshe
12 years ago (2008-12-01 22:04:56 UTC) #1
Mike Belshe
Add Jar/Nicolas to the reviewer list while Darin is out
12 years ago (2008-12-01 22:24:58 UTC) #2
Nicolas Sylvain
LGTM
12 years ago (2008-12-01 22:53:39 UTC) #3
jar (doing other things)
LGTM
12 years ago (2008-12-02 00:34:22 UTC) #4
darin (slow to review)
12 years ago (2008-12-02 01:37:22 UTC) #5
LGTM

http://codereview.chromium.org/13023/diff/1/3
File base/timer.h (right):

http://codereview.chromium.org/13023/diff/1/3#newcode139
Line 139: virtual ~TimerTask() {
It is nice that delayed Tasks have the guarantee of being destroyed if not Run. 
We should work to make the same thing be true for non-delayed Tasks.

It would be good to add a comment about the significance of this ClearBaseTimer
call w.r.t. MessageLoop destruction.

Powered by Google App Engine
This is Rietveld 408576698