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

Issue 635943 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Aug 2016
Cc:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 3
Type: Bug



Sign in to add a comment

disable_outdated_build_detector tests fail with LLD on Windows

Project Member Reported by r...@chromium.org, Aug 9 2016

Issue description

These tests have failed on the Win LLD TOT bot since they were added:
https://build.chromium.org/p/chromium.fyi/builders/CrWinClangLLD%20tester/builds/1087

Some of the failures look like this:
[ RUN      ] UserLevel/DisableOutdatedBuildDetectorTest.MultiOrganicChrome/0
../../chrome/tools/disable_outdated_build_detector/disable_outdated_build_detector_unittest.cc(151): error: Value of: DisableOutdatedBuildDetector(command_line_)
  Actual: 4-byte object <E9-03 00-00>
Expected: ExitCode::BOTH_BRANDS_UPDATED
Which is: 4-byte object <E8-03 00-00>
../../chrome/tools/disable_outdated_build_detector/disable_outdated_build_detector_unittest.cc(88): error: Value of: key.ReadValueDW(installer::kInstallerResult, &value)
  Actual: 2
Expected: 0L
Which is: 0
../../chrome/tools/disable_outdated_build_detector/disable_outdated_build_detector_unittest.cc(156): error: Value of: ReadBrand(chrome_distribution_).c_str()
  Actual: L"GGLS"
Expected: L"AOHY"

This sounds like some kind of failure to run dynamic initializers in LLD.
 

Comment 1 by grt@chromium.org, Aug 10 2016

Cc: -grt@chromium.org
Labels: OS-Windows
Owner: grt@chromium.org
Status: Started (was: Untriaged)
Trying to repro locally.

Comment 2 by grt@chromium.org, Aug 10 2016

I'm not sure if this is a compiler/linker bug, or a code bug. The problem is that there are two extern string constants with the same (empty) value in Chromium builds. clang/lld is collapsing them together so that they have the same pointer value.

// App GUIDs for Google Chrome and the Google Chrome binaries.
#if defined(GOOGLE_CHROME_BUILD)
const wchar_t kChromeAppGuid[] = L"{8A69D345-D564-463c-AFF1-A69D9E530F96}";
const wchar_t kBinariesAppGuid[] = L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}";
#else
const wchar_t kChromeAppGuid[] = L"";
const wchar_t kBinariesAppGuid[] = L"";
#endif

I can easily put gibberish in there to prevent this, but I would not expect these to be folded together like this. Am I relying on undefined behavior (two constants having distinct pointer values), or is clang/lld doing something wrong?

Comment 3 by r...@chromium.org, Aug 10 2016

I think your code is correct from a C++ language perspective, objects are supposed to have identity and this is supposed to work:
static char a, b;
void f() { assert(&a != &b); }

I don't think there's anything special about wide character arrays that means their addresses are not important. String literals can definitely get folded, so the result of '"a" == "a"' is unpredictable, but that's not what's going on here.

Comment 4 by thakis@chromium.org, Aug 10 2016

So this is an lld icf bug then?

Comment 5 by r...@chromium.org, Aug 10 2016

ICF of only code is also non-conforming, so it's hard to say whether this is a bug or a feature. You can call it a bug on the basis that it introduces compatibility issues with MSVC, but some users might appreciate the more aggressive deduplication of constants.

Comment 6 by grt@chromium.org, Aug 10 2016

Is this something you want to fix in lld?

Comment 7 by ruiu@google.com, Aug 10 2016

I inclined to say no, because the unsafe ICF optimization is on by default on Windows anyways. We are a little bit more aggressive than what MSVC does, but in spirit we are doing what they intend to do.

Comment 8 by grt@chromium.org, Aug 11 2016

I have a fix in https://codereview.chromium.org/2236843002/. I'd appreciate it if one of y'all could take a look and LGTM+CQ if you like it. It avoids the pointer comparison altogether rather than hacking around the linker's behavior. Thanks.

Comment 10 by grt@chromium.org, Aug 15 2016

Status: Fixed (was: Started)
(This kind of feels like an lld bug to me tbh. I don't remember seeing this type of problem with gold's heuristic. I suppose it doesn't trigger very often though.)

Sign in to add a comment