New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 616860 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Jun 2016
Cc:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 3
Type: Bug



Sign in to add a comment

base_unittests: AllocatorShimTest fails with GCC -O2

Project Member Reported by bcf@chromium.org, Jun 2 2016

Issue description

Note: 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

 

Comment 1 by bcf@chromium.org, Jun 2 2016

Cc: primiano@chromium.org
We 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
Project Member

Comment 2 by bugdroid1@chromium.org, 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

Comment 3 by bcf@chromium.org, Jun 2 2016

Status: Fixed (was: Started)

Sign in to add a comment