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

Issue 548011: Avoid a strict aliasing issue in LazyInstance. (Closed)

Created:
10 years, 11 months ago by Craig
Modified:
9 years, 7 months ago
CC:
chromium-reviews_googlegroups.com
Visibility:
Public.

Description

Avoid a strict aliasing issue in LazyInstance. The key change here is to use the return value from placement new rather than casting buf_. Avoiding the cast avoids the strict aliasing issue. BUG=28749 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=41434

Patch Set 1 #

Total comments: 1

Patch Set 2 : s/NeedInstance/NeedsInstance and align buf_ #

Patch Set 3 : use align(16) to support older gcc on tryserver #

Total comments: 3

Patch Set 4 : Revert alignment change so I can commit patch set 1. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+44 lines, -35 lines) Patch
M base/lazy_instance.h View 1 2 3 3 chunks +21 lines, -15 lines 0 comments Download
M base/lazy_instance.cc View 1 1 chunk +23 lines, -20 lines 0 comments Download

Messages

Total messages: 11 (0 generated)
Craig
This is the alternative to my other attempt at fixing this (which was at http://codereview.chromium.org/519045). ...
10 years, 11 months ago (2010-01-12 19:15:05 UTC) #1
darin (slow to review)
LGTM http://codereview.chromium.org/548011/diff/1/3 File base/lazy_instance.h (right): http://codereview.chromium.org/548011/diff/1/3#newcode74 base/lazy_instance.h:74: bool NeedInstance(); nit: in the CL description, you ...
10 years, 11 months ago (2010-01-12 20:32:14 UTC) #2
Dean McNamee
This code is tricky, so I'll try to review it when I get a chance. ...
10 years, 11 months ago (2010-01-13 00:59:31 UTC) #3
Craig
I've done s/NeedInstance/NeedsInstance as per Darin and aligned the buffer as suggested by jamesr. I ...
10 years, 11 months ago (2010-01-13 14:58:42 UTC) #4
darin (slow to review)
http://codereview.chromium.org/548011/diff/2007/2009 File base/lazy_instance.h (right): http://codereview.chromium.org/548011/diff/2007/2009#newcode124 base/lazy_instance.h:124: int8 buf_[sizeof(Type)] __attribute__((aligned(16))); i'm confused about the need to ...
10 years, 11 months ago (2010-01-13 18:04:03 UTC) #5
Craig
On 2010/01/13 18:04:03, darin wrote: > http://codereview.chromium.org/548011/diff/2007/2009 > File base/lazy_instance.h (right): > > http://codereview.chromium.org/548011/diff/2007/2009#newcode124 > ...
10 years, 11 months ago (2010-01-13 18:56:35 UTC) #6
Peter Kasting
http://codereview.chromium.org/548011/diff/2007/2009 File base/lazy_instance.h (right): http://codereview.chromium.org/548011/diff/2007/2009#newcode124 base/lazy_instance.h:124: int8 buf_[sizeof(Type)] __attribute__((aligned(16))); On 2010/01/13 18:04:03, darin wrote: > ...
10 years, 11 months ago (2010-01-13 19:25:02 UTC) #7
jamesr
http://codereview.chromium.org/548011/diff/2007/2009 File base/lazy_instance.h (right): http://codereview.chromium.org/548011/diff/2007/2009#newcode124 base/lazy_instance.h:124: int8 buf_[sizeof(Type)] __attribute__((aligned(16))); On 2010/01/13 18:04:03, darin wrote: > ...
10 years, 11 months ago (2010-01-13 21:05:35 UTC) #8
Craig
Here are the msvc alignment rules btw. http://msdn.microsoft.com/en-us/library/83ythb65.aspx
10 years, 11 months ago (2010-01-14 06:48:13 UTC) #9
Craig
So I haven't forgotten about this :) I have sifted through the current users of ...
10 years, 10 months ago (2010-02-10 15:24:10 UTC) #10
Craig
10 years, 9 months ago (2010-03-11 18:53:48 UTC) #11
I'm going to land the first patch set here, probably tomorrow, with the
(trivial) nits addressed. That patch has a LGTM from Darin. If anyone has any
objections, yell soon please to stop me. I've sent it to the try servers again
of course to confirm it's still happy and have been running it locally for ages
without issues.

Powered by Google App Engine
This is Rietveld 408576698