[LLVMbugs] [Bug 21112] New: Allow using ASan and UBSan together on OSX

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Oct 1 01:18:39 PDT 2014


            Bug ID: 21112
           Summary: Allow using ASan and UBSan together on OSX
           Product: compiler-rt
           Version: unspecified
          Hardware: PC
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: compiler-rt
          Assignee: glider at google.com
          Reporter: glider at google.com
                CC: llvmbugs at cs.uiuc.edu, samsonov at google.com
    Classification: Unclassified

Copying my own letter here:

I think the UBSan+ASan hybrid is fundamentally broken on OSX for at
least the two following reasons:

1. Parts of sanitizer_common from libclang_rt.ubsan_osx.a are linked
into the main executable, which also depends on
libclang_rt.asan_osx_dynamic.dylib. The latter contains its own copy
of sanitizer_common bits, so the two tools cannot share data (e.g.
common_flags()) like they do on Linux.

2. UBSan may be initialized too late on OSX. Because there's no
.preinit_array, we can only rely on static constructors. Because the
ASan runtime library must be preloaded into the executable, when
ASan's static constructor is called for the first time, it sets the
appropriate env and calls exec() on the binary. After that ASan
runtime library is initialized before other libraries that the program
UBSan is initialized way later, when the main executable's
constructors are invoked. Not sure if that's a big issue, but it could
be in the case other libraries are also built with UBSan.

Looks like we need to put the necessary UBSan parts into the dynamic
library (something like libclang_rt.asan_ubsan_osx_dynamic.dylib) and
link that library in the case both -fsanitize=address and
-fsanitize=integer are passed to the driver. It's a good question how
to initialize UBSan in this case.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141001/b7f07134/attachment.html>

More information about the llvm-bugs mailing list