This is an archive of the discontinued LLVM Phabricator instance.

[asan][test] Fix tests or mark XFAIL for MinGW target
ClosedPublic

Authored by alvinhochun on Mar 28 2023, 9:22 AM.

Details

Summary

After this change, check-asan-dynamic should pass on x86_64 MinGW
target, using the llvm-mingw toolchain.

The following is a list of issues fixed:

  • asan_str_test.cpp: Exclude unintercepted functions on MinGW.
  • asan_test.cpp: Work around regex limitation of gtest on Windows, which only affects MinGW target because long double has different size to double.
  • TestCases/Windows/report_after_syminitialize.cpp: Added build command specifically for MinGW.
  • Other tests: Mark XFAIL for various reasons. Some of them need further investigation.

Depends on D146908, D147232 and D147057

Diff Detail

Event Timeline

alvinhochun created this revision.Mar 28 2023, 9:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 28 2023, 9:22 AM
Herald added subscribers: Enna1, pengfei. · View Herald Transcript
alvinhochun requested review of this revision.Mar 28 2023, 9:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 28 2023, 9:22 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
mstorsjo added inline comments.Mar 28 2023, 1:27 PM
compiler-rt/lib/asan/tests/asan_str_test.cpp
114

For cases like these, it should hopefully not be hard to move the strnlen function from libmingwex.a into libmsvcr*.a, to make it use the one from UCRT.

compiler-rt/lib/asan/tests/asan_test.cpp
208

If this is specific to Windows, why is this different from the case with MSVC/clang-cl?

compiler-rt/test/asan/TestCases/Windows/report_after_syminitialize.cpp
6

In which way does it fail - what does %clangxx_asan expand to in that case?

compiler-rt/test/asan/TestCases/alloca_big_alignment.cpp
9 ↗(On Diff #509046)

I think the changes from long to intptr_t could go into a separate patch, as those are useful to have in any case. I guess the thing is that clang warns about different things in clang-cl mode than in regular gcc-style mode, and this warning wasn't visible in clang-cl mode?

compiler-rt/test/asan/TestCases/atoll_strict.c
14

Or just generalize into `{{.*windows-.*}}?

Fix Debian tests, hopefully.

alvinhochun added inline comments.Mar 28 2023, 2:01 PM
compiler-rt/lib/asan/tests/asan_test.cpp
208

MSVC target shouldn't reach here anyway because if (sizeof(long double) == sizeof(double)) is true. I guess I can change it to _WIN32 though.

compiler-rt/test/asan/TestCases/Windows/report_after_syminitialize.cpp
6

It fails because it's missing -ldbghelp, which MSVC target doesn't need thanks to the #pragma lib comment.

compiler-rt/test/asan/TestCases/alloca_big_alignment.cpp
9 ↗(On Diff #509046)

It actually errors out on MinGW target in my test. No idea why that would not be an issue for MSVC target.

compiler-rt/test/asan/TestCases/atoll_strict.c
14

I was thinking of making it more explicit to point out that, yes this test is XFAIL for both msvc and gnu targets.

Appease clang-format

pengfei added inline comments.Mar 28 2023, 6:27 PM
compiler-rt/lib/asan/tests/asan_test.cpp
208

Clang has option to override it, see https://godbolt.org/z/1x9Pd9Tfx

mstorsjo added inline comments.Mar 29 2023, 12:35 AM
compiler-rt/lib/asan/tests/asan_test.cpp
208

Thanks - although we're not interested in making the MSVC target run this code - I was just wondering why this issue only appeared now.

@alvinhochun Changing it to _WIN32 probably is a good idea for clarity, and then mention the long double issue in the commit message regarding that particular change.

compiler-rt/test/asan/TestCases/Windows/report_after_syminitialize.cpp
6

Ok, I see. This is kinda tricky and somewhat brittle, but I guess it can be ok.

compiler-rt/test/asan/TestCases/atoll_strict.c
14

Ok, fair enough.

alvinhochun edited the summary of this revision. (Show Details)

Change as per comments

mstorsjo accepted this revision.Mar 30 2023, 1:24 AM

Overall LGTM, but I think it maybe would be nicer to split out the long->intptr_t changes into a separate patch.

This revision is now accepted and ready to land.Mar 30 2023, 1:24 AM
alvinhochun edited the summary of this revision. (Show Details)

Split the long -> intptr_t change to D147232

mstorsjo accepted this revision.Mar 30 2023, 2:05 PM

LGTM, thanks!

I'm still not entirely a fan of the brittle test that tries to link in two different ways though, but I guess it can be tolerable if it's only this one test.

This revision was automatically updated to reflect the committed changes.