base_unittests: AllocatorShimTest fails with GCC -O2 |
||
Issue descriptionNote: This is based on internal b/28801531 Version: master OS: Chromecast What steps will reproduce the problem? Build and run base_unittests What is the expected output? AllocatorShimTest should pass What do you see instead? [ RUN ] AllocatorShimTest.NewHandlerConcurrency ../../base/allocator/allocator_shim_unittest.cc:153: Failure Value of: reinterpret_cast<uintptr_t>(res) Actual: 66 Expected: 0x42u Which is: 66
,
Jun 2 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/2dcb3524b6daaa812c2af10baf4b1f4b1a6a25ba commit 2dcb3524b6daaa812c2af10baf4b1f4b1a6a25ba Author: bcf <bcf@chromium.org> Date: Thu Jun 02 22:10:22 2016 Replace 0x42 with 0x420 in ThreadDelegateForNewHandlerTest On GCC -O2, the comparison operator between realloc's result and the uintptr_t 0x42 is optimized away. 0x42 is not aligned, so the compiler assumes realloc cannot return this value. BUG= 616860 BUG=internal b/28801531 Review-Url: https://codereview.chromium.org/2032753002 Cr-Commit-Position: refs/heads/master@{#397526} [modify] https://crrev.com/2dcb3524b6daaa812c2af10baf4b1f4b1a6a25ba/base/allocator/allocator_shim_unittest.cc
,
Jun 2 2016
|
||
►
Sign in to add a comment |
||
Comment 1 by bcf@chromium.org
, Jun 2 2016We found that this is due to this section of code: class ThreadDelegateForNewHandlerTest : public PlatformThread::Delegate { ... void ThreadMain() override { ... void* res = realloc(reinterpret_cast<void*>(0x42ul), 1); EXPECT_EQ(0x42u, reinterpret_cast<uintptr_t>(res)); The compiler assumes that realloc cannot return an unaligned value. Changing 0x42 to 0x420 solves the problem. This is implemented in crrev.com/2032753002