[PATCH] UBSan on Windows

Aaron Ballman aaron at aaronballman.com
Fri Oct 24 13:22:59 PDT 2014


On Fri, Oct 24, 2014 at 2:38 PM, Timur Iskhodzhanov <timurrrr at google.com> wrote:
> OK, so I've tried running your patch locally using ninja.
> I had to add Windows to the list of supported OSes in
> test/ubsan/lit-something to run any tests.
>
> Then I got almost all the tests failing, see attached log.  Some
> failueres are caused by POSIX assumptions (like header file names),
> some fail to link (probably due to insufficient RTL implementation).
> I think most of the test failures should be addressed before ubsan is
> considered functional.

Agreed, and I can reproduce this locally with ninja as well.

> I'm not sure if enabling ubsan compilation without any tests passing
> is a good idea?

Something's amiss, and I've not been able to deduce what. Picking on
this failure from Ninja:

********************
FAIL: UndefinedBehaviorSanitizer-AddressSanitizer ::
TestCases/Integer/umul-overflow.cpp (4 of 58)
******************** TEST 'UndefinedBehaviorSanitizer-AddressSanitizer
:: TestCases/Integer/umul-overflow.cpp' FAILED ********************
Script:
--
D:/src/llvm-trunk/OUT/./bin/clang.exe -fsanitize=address
-fsanitize=unsigned-integer-overflow
D:\src\llvm-trunk\projects\compiler-rt\test\ubsan\TestCases\Integer\umul-overflow.cpp
-o D:\src\llvm-trunk\OUT\projects\compiler-rt\test\ubsan\AsanConfig\TestCases\Integer\Output\umul-overflow.cpp.tmp
&&  D:\src\llvm-trunk\OUT\projects\compiler-rt\test\ubsan\AsanConfig\TestCases\Integer\Output\umul-overflow.cpp.tmp
2>&1 | FileCheck
D:\src\llvm-trunk\projects\compiler-rt\test\ubsan\TestCases\Integer\umul-overflow.cpp
--
Exit Code: 1120

Command Output (stdout):
--
Command 0: "D:/src/llvm-trunk/OUT/./bin/clang.exe"
"-fsanitize=address" "-fsanitize=unsigned-integer-overflow"
"D:\src\llvm-trunk\projects\compiler-rt\test\ubsan\TestCases\Integer\umul-overflow.cpp"
"-o" "D:\src\llvm-trunk\OUT\projects\compiler-rt\test\ubsan\AsanConfig\TestCases\Integer\Output\umul-overflow.cpp.tmp"
Command 0 Result: 1120
Command 0 Output:
   Creating library
D:\src\llvm-trunk\OUT\projects\compiler-rt\test\ubsan\AsanConfig\TestCases\Integer\Output\umul-overflow.cpp.lib
and object D:\src\llvm-trunk\OUT\projects\compiler-rt\test\ubsan\AsanConfig\TestCases\Integer\Output\umul-overflow.cpp.exp

umul-overflow-8aa4ef.o : error LNK2019: unresolved external symbol
___ubsan_handle_mul_overflow referenced in function _main

D:\src\llvm-trunk\OUT\projects\compiler-rt\test\ubsan\AsanConfig\TestCases\Integer\Output\umul-overflow.cpp.tmp
: fatal error LNK1120: 1 unresolved externals


Command 0 Stderr:
D:\src\llvm-trunk\projects\compiler-rt\test\ubsan\TestCases\Integer\umul-overflow.cpp:13:27:
warning: overflow in expression; result is -2147450881 with type 'int'
[-Winteger-overflow]

  (void)(uint16_t(0xffff) * uint16_t(0x8001));
                          ^
1 warning generated.

clang.exe: error: linker command failed with exit code 1120 (use -v to
see invocation)

---------------------------------
This is a linker issue. When I run the test manually, I get:


E:\llvm\2013>Release\bin\clang.exe -fsanitize=signed-integer-overflow -g -c "E:\
Aaron Ballman\Desktop\test.cpp"
E:\Aaron Ballman\Desktop\test.cpp:13:27: warning: overflow in expression; result

      is -2147450881 with type 'int' [-Winteger-overflow]
  (void)(uint16_t(0xffff) * uint16_t(0x8001));
                          ^
1 warning generated.

E:\llvm\2013>link /debug /incremental:no /out:a.out /nologo test.o /defaultlib:l
ibcmt Release\lib\clang\3.6.0\lib\windows\Release\clang_rt.ubsan-i386.lib Releas
e\lib\clang\3.6.0\lib\windows\Release\clang_rt.san-i386.lib
   Creating library a.lib and object a.exp

E:\llvm\2013>a.out
E:\Aaron Ballman\Desktop\test.cpp:13:27: runtime error: signed integer overflow:
 65535 * 32769 cannot be represented in type 'int'

So it seems that the tests CAN pass, it's just that we have more CMake
issues on Windows, even with Ninja.

I do agree that there should be some tests passing before we switch
this "on", of course. But it seems like what is really needed is some
CMake work before we can tell just where we're at with regards to the
test suite.

What do you think?

Thanks!

~Aaron



More information about the llvm-commits mailing list