This is an archive of the discontinued LLVM Phabricator instance.

UBSan: Enable runtime library tests on Windows, and get most tests passing.
ClosedPublic

Authored by pcc on Jul 1 2015, 12:16 AM.

Details

Summary

Specifically:

  • Disable int128 tests on Windows, as MSVC cl.exe does not support int128, so we might not have been able to build the runtime with int128 support.
  • XFAIL the vptr tests as we lack Microsoft ABI support.
  • XFAIL enum.cpp as UBSan fails to add the correct instrumentation code for some reason.
  • Modify certain tests that build executables multiple times to use unique names for each executable. This works around a race condition observed on Windows.
  • Implement IsAccessibleMemoryRange for Windows to fix the last misaligned.cpp test.
  • Introduce a substitution for testing crashes on Windows using KillTheDoctor.

Diff Detail

Repository
rL LLVM

Event Timeline

pcc updated this revision to Diff 28849.Jul 1 2015, 12:16 AM
pcc retitled this revision from to UBSan: Enable runtime library tests on Windows, and get most tests passing..
pcc updated this object.
pcc edited the test plan for this revision. (Show Details)
pcc added a reviewer: samsonov.
pcc added a subscriber: Unknown Object (MLST).
samsonov added inline comments.Jul 1 2015, 11:31 AM
test/ubsan/CMakeLists.txt
7 ↗(On Diff #28849)

See comment below - it should probably go to SANITIZER_COMMON_LIT_TEST_DEPS

test/ubsan/TestCases/Integer/div-zero.cpp
6 ↗(On Diff #28849)

Not sure I follow this... So, Clang on Windows supports int128, and has this macro defined, but we build UBSan runtime with MSVC, which might not have support for int128?

test/ubsan/TestCases/Integer/usub-overflow.cpp
1 ↗(On Diff #28849)

What kind of race condition in Windows do you refer to?

test/ubsan/TestCases/Misc/deduplication.cpp
14 ↗(On Diff #28849)

Wow, you actually need to flush stderr on Windows? (TIL)

test/ubsan/TestCases/TypeCheck/vptr.cpp
29 ↗(On Diff #28849)

Can you just define cxxabi to False on Windows?

test/ubsan/lit.common.cfg
54 ↗(On Diff #28849)

It would be great to actually fix this in not/KillTheDoctor tools... but if we want a quick workaround for now,
we should at least move it to test/lit.common.cfg, as there can be other compiler-rt tests using not --crash,
so this substitution should be available for them.

pcc updated this revision to Diff 28930.Jul 1 2015, 8:12 PM
  • Use page size from GetNativeSystemInfo instead of hardcoded page size from GetPageSize().

    Fixes a test failure when targeting 32-bit Windows. Not really clear where the hardcoded value comes from or if we should start returning the GetNativeSystemInfo() value from GetPageSize() (if I try it, I see test failures elsewhere).
  • Address review comments
test/ubsan/CMakeLists.txt
7 ↗(On Diff #28849)

Done

test/ubsan/TestCases/Integer/div-zero.cpp
6 ↗(On Diff #28849)

Exactly.

test/ubsan/TestCases/Integer/usub-overflow.cpp
1 ↗(On Diff #28849)

I was sometimes seeing file access errors for the test executable from the linker. I think Windows keeps executable files open for a little while after the process terminates.

test/ubsan/TestCases/Misc/deduplication.cpp
14 ↗(On Diff #28849)

Yes, this was a little surprising to me as well.

test/ubsan/TestCases/TypeCheck/vptr.cpp
29 ↗(On Diff #28849)

Done

test/ubsan/lit.common.cfg
54 ↗(On Diff #28849)

Done

samsonov accepted this revision.Jul 2 2015, 12:10 PM
samsonov edited edge metadata.

LGTM

test/ubsan/CMakeLists.txt
7 ↗(On Diff #28930)

You can now delete this part

test/ubsan/TestCases/TypeCheck/misaligned.cpp
61 ↗(On Diff #28930)

Is there a bug for weird column info on Windows?

This revision is now accepted and ready to land.Jul 2 2015, 12:10 PM
pcc added inline comments.Jul 2 2015, 3:08 PM
test/ubsan/CMakeLists.txt
7 ↗(On Diff #28930)

Done

test/ubsan/TestCases/TypeCheck/misaligned.cpp
61 ↗(On Diff #28930)

Filed PR24024.

This revision was automatically updated to reflect the committed changes.