|
|
Created:
9 years ago by stevenjb Modified:
9 years ago CC:
chromium-reviews, brettw-cc_chromium.org Base URL:
svn://svn.chromium.org/chrome/trunk/src Visibility:
Public. |
DescriptionDon't delete g_vlog_info
Fixes a race on startup. See issue for details.
BUG=chromium-os:20865
TEST=Ensure logging, including VLOG, works.
[email protected]
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=112828
Patch Set 1 #Patch Set 2 : Limit g_vlog_info to two instances and track both. #
Total comments: 11
Patch Set 3 : Add anon namespace and simplify logic #
Total comments: 1
Patch Set 4 : . #Patch Set 5 : Rebase #Patch Set 6 : Move global g_dcheck_state out of anonymous namespace #Messages
Total messages: 22 (0 generated)
@oshima: Will this change trigger any memory leak detection? I noticed that we were never deleting g_log_info before, so allocating and not deleting it twice seems like an acceptable leak, but it would also be easy to keep a VlogInfo vector, or vector of pointers, if that is required or preferred.
On 2011/11/30 21:33:48, Steven Bennetts wrote: > @oshima: Will this change trigger any memory leak detection? I noticed that we > were never deleting g_log_info before, so allocating and not deleting it twice > seems like an acceptable leak, but it would also be easy to keep a VlogInfo > vector, or vector of pointers, if that is required or preferred. It probably will. Am I correct that this is because the vlog object gets recreated when we redirect output to users dir, while other thread may be writing to vlog? I agree that if this happens only once during lifetime, it's acceptable, although I still like to avoid using suppression, if that's all possible. Since this must happen at most once, how about just having secondary global pointer so that we can catch leak if this happens 3rd time?
That makes sense, done. PTAL
On 2011/12/01 00:12:25, Steven Bennetts wrote: > That makes sense, done. > PTAL (Oh, and yes, your assumption is correct. The second time InitLogging gets called is from RedirectChromeLogging in chrome/common/logging_chrome.cc)
http://codereview.chromium.org/8757002/diff/3002/base/logging.cc File base/logging.cc (right): http://codereview.chromium.org/8757002/diff/3002/base/logging.cc#newcode369 base/logging.cc:369: VlogInfo* vlog_info = NULL; how about DCHECK(!vlog_info_second); vlog_info_second = vlog_info; inside if block below?
http://codereview.chromium.org/8757002/diff/3002/base/logging.cc File base/logging.cc (right): http://codereview.chromium.org/8757002/diff/3002/base/logging.cc#newcode369 base/logging.cc:369: VlogInfo* vlog_info = NULL; I'm not sure I understand your suggestion. I put the CHECK above to do it as early as possible, but I could move it into the if() block if that woud be more clear. I used CHECK instead of DCHECK to prevent a leak from showing up, but I could use DCHECK if we are ok with that. (My experience is that ChromeOS Debug builds rarely get run outside of some tests). On 2011/12/01 16:28:48, oshima wrote: > how about > > DCHECK(!vlog_info_second); > vlog_info_second = vlog_info; > > inside if block below? >
http://codereview.chromium.org/8757002/diff/3002/base/logging.cc File base/logging.cc (right): http://codereview.chromium.org/8757002/diff/3002/base/logging.cc#newcode68 base/logging.cc:68: VlogInfo* g_vlog_info_first = NULL; static and/or anon namespace for these two? (I guess the other globals in this file, too) http://codereview.chromium.org/8757002/diff/3002/base/logging.cc#newcode69 base/logging.cc:69: VlogInfo* g_vlog_info_second = NULL; might be clearer to just have "g_vlog_info" and "g_vlog_info_prev" instead of three variables with two equal. http://codereview.chromium.org/8757002/diff/3002/base/logging.cc#newcode367 base/logging.cc:367: CHECK(g_vlog_info_second == NULL); usual style is !g_vlog_info_second http://codereview.chromium.org/8757002/diff/3002/base/logging.cc#newcode380 base/logging.cc:380: if (!g_vlog_info_first) { rewrite to use positive test, i.e. if (g_vlog_info_first). http://codereview.chromium.org/8757002/diff/3002/base/logging.cc#newcode382 base/logging.cc:382: g_vlog_info = g_vlog_info_first; i couldn't understand what these two lines were doing until I read them a couple times. what about: g_vlog_info = v_log_info; if (g_vlog_info_first) { g_vlog_info_second = v_log_info; } else { g_vlog_info_first = v_log_info; }
PTAL http://codereview.chromium.org/8757002/diff/3002/base/logging.cc File base/logging.cc (right): http://codereview.chromium.org/8757002/diff/3002/base/logging.cc#newcode68 base/logging.cc:68: VlogInfo* g_vlog_info_first = NULL; On 2011/12/01 17:03:24, akalin wrote: > static and/or anon namespace for these two? (I guess the other globals in this > file, too) Done. http://codereview.chromium.org/8757002/diff/3002/base/logging.cc#newcode69 base/logging.cc:69: VlogInfo* g_vlog_info_second = NULL; On 2011/12/01 17:03:24, akalin wrote: > might be clearer to just have "g_vlog_info" and "g_vlog_info_prev" instead of > three variables with two equal. Done. http://codereview.chromium.org/8757002/diff/3002/base/logging.cc#newcode369 base/logging.cc:369: VlogInfo* vlog_info = NULL; On 2011/12/01 16:51:41, Steven Bennetts wrote: > I'm not sure I understand your suggestion. I put the CHECK above to do it as > early as possible, but I could move it into the if() block if that woud be more > clear. I used CHECK instead of DCHECK to prevent a leak from showing up, but I > could use DCHECK if we are ok with that. (My experience is that ChromeOS Debug > builds rarely get run outside of some tests). > > On 2011/12/01 16:28:48, oshima wrote: > > how about > > > > DCHECK(!vlog_info_second); > > vlog_info_second = vlog_info; > > > > inside if block below? > > > After chatting + fred's feedback, I think this will be simpler. Kept it as a CHECK instead of a DCHECK however to prevent more subtle races or memory failures. http://codereview.chromium.org/8757002/diff/3002/base/logging.cc#newcode382 base/logging.cc:382: g_vlog_info = g_vlog_info_first; On 2011/12/01 17:03:24, akalin wrote: > i couldn't understand what these two lines were doing until I read them a couple > times. what about: > > g_vlog_info = v_log_info; > if (g_vlog_info_first) { > g_vlog_info_second = v_log_info; > } else { > g_vlog_info_first = v_log_info; > } Re-factored with oshima's feedback also.
LGTM http://codereview.chromium.org/8757002/diff/10001/base/logging.cc File base/logging.cc (right): http://codereview.chromium.org/8757002/diff/10001/base/logging.cc#newcode425 base/logging.cc:425: VlogInfo* vlog_info = g_vlog_info; did you mean to change this? I don't know if this adds much
LGTM , other than the comment akalin made.
On 2011/12/01 19:31:19, akalin wrote: > LGTM > > http://codereview.chromium.org/8757002/diff/10001/base/logging.cc > File base/logging.cc (right): > > http://codereview.chromium.org/8757002/diff/10001/base/logging.cc#newcode425 > base/logging.cc:425: VlogInfo* vlog_info = g_vlog_info; > did you mean to change this? I don't know if this adds much Yes, that's intentional, to avoid the very unlikely edge case of: if (g_vlog_info [first instance]) g_vlog_info [second_instance]->GetVlogLevel() It's not currently relevant, and the optimizer will likely do that anyway, but I prefer to be explicit with these things. I should really add a comment though.
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/[email protected]/8757002/12002
Presubmit check for 8757002-12002 failed and returned exit status 1. Running presubmit commit checks ... ** Presubmit ERRORS ** Missing LGTM from an OWNER for: base/logging.cc,base/logging.h Presubmit checks took 1.1s to calculate.
+ thakis, willchan for owners approval
Sounds more like Will's type of thing :-)
Will still isn't around, bus sicne oshima + akalin approved, I'm going to TBR this. [email protected]
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/[email protected]/8757002/12002
Presubmit check for 8757002-12002 failed and returned exit status 1. Running presubmit commit checks ... ** Presubmit ERRORS ** Missing LGTM from an OWNER for: base/logging.cc,base/logging.h Presubmit checks took 1.6s to calculate. Was the presubmit check useful? Please send feedback & hate mail to [email protected]!
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/[email protected]/8757002/12002
Try job failure for 8757002-12002 (retry) on win_rel for step "compile" (clobber build). It's a second try, previously, step "compile" failed. http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=win_rel&nu...
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/[email protected]/8757002/15002
Change committed as 112828 |