[PATCH] D18212: [sanitizer] On OS X, verify that interceptors work and abort if not, take 2

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 16 13:08:02 PDT 2016

kubabrecka added a comment.

In http://reviews.llvm.org/D18212#376617, @samsonov wrote:

> This is really unfortunate. I also don't like adding the runtime flag for the sake of TSan unit test. Why can we call DisableReexec() from ASan unit tests, but not from TSan ones? The former also use static runtime on OS X?

The difference is in the interceptors of new/delete C++ operators.  In ASan, we have `INTERCEPTOR(void *, _Znwm, size_t size)`, which is just a regular interceptor, and in the static library, it doesn't work (just as all other interceptors).  But in TSan, we declare a custom operator with `void *operator new(__sanitizer::uptr size)`, which **works even in the static library**.  The `TEST()` macro from GTest expands to a static initializer that calls `new`, which gets intercepted and TSan will initialize at this point.  We'd need to call `DisableReexec()` before any other initializers.

One solution would be to put the static initializer that calls `DisableReexec()` to a file that's first in the CMake source file list.  That's quite fragile, I don't think we want to depend on the order of file lists in CMake.

Converting the new/delete operators to be the same as ASan uncovers some test failures and needs more changes/fixes.  One thing that breaks is demangling in stack trace, as things like `wrap__Znwm` will appear (instead of `operator new`), because the `wrap_` prefix prevents demangling.  This bug currently exist in ASan as well, but no testcase covers it (on OS X).  But TSan expects this to work in a few lit tests already.


More information about the llvm-commits mailing list