ramosian-glider / sanitizers

0 stars 0 forks source link

CHECK failed: ((tsd_key_inited)) != (0) with dynamic runtime #124

Closed ramosian-glider closed 9 years ago

ramosian-glider commented 9 years ago

Originally reported on Google Code with ID 123

$ cat p.c
int main() { 
  return 0;
}
$ /Users/glider/src/asan/llvm/build/Release+Asserts/bin/clang -faddress-sanitizer p.c
-o p
$ ASAN_OPTIONS=verbosity=1 ./p
==76928== Parsed ASAN_OPTIONS: verbosity=1
==76928== exec()-ing the program with
==76928== DYLD_INSERT_LIBRARIES=/Users/glider/src/asan/llvm/build/Release+Asserts/lib/clang/3.2/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
==76928== to enable ASan wrappers.
==76928== Set ASAN_OPTIONS=allow_reexec=0 to disable this.
==76928== Parsed ASAN_OPTIONS: verbosity=1
|| `[0x200000000000, 0x7fffffffffff]` || HighMem    ||
|| `[0x140000000000, 0x1fffffffffff]` || HighShadow ||
|| `[0x120000000000, 0x13ffffffffff]` || ShadowGap  ||
|| `[0x100000000000, 0x11ffffffffff]` || LowShadow  ||
|| `[0x000000000000, 0x0fffffffffff]` || LowMem     ||
MemToShadow(shadow): 0x120000000000 0x123fffffffff 0x128000000000 0x13ffffffffff
red_zone=64
malloc_context_size=30
SHADOW_SCALE: 3
SHADOW_GRANULARITY: 8
SHADOW_OFFSET: 100000000000
==76928== Installed the sigaction for signal 11
==76928== Installed the sigaction for signal 10
==76928== T0: stack [0x7fff5b5b3000,0x7fff5bdb3000) size 0x800000; local=0x7fff5bdb1d40
==76928== AddressSanitizer Init done

$ DYLD_INSERT_LIBRARIES=/Users/glider/src/asan/llvm/build/Release+Asserts/lib/clang/3.2/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
ASAN_OPTIONS=verbosity=1 ./p
=================================================================
==77666== Sanitizer CHECK failed: /Users/glider/src/asan/llvm/projects/compiler-rt/lib/asan/asan_posix.cc:109
((tsd_key_inited)) != (0) (0, 0)

Reported by ramosian.glider on 2012-10-25 14:52:24

ramosian-glider commented 9 years ago
Regression range: r164900 (works) -- r166000 (does not)

Reported by ramosian.glider on 2012-10-26 08:59:34

ramosian-glider commented 9 years ago
This has been caused by r165307, namely the following part:

=======================================================
@@ -382,9 +372,7 @@

 #if ASAN_INTERCEPT_STRDUP
 INTERCEPTOR(char*, strdup, const char *s) {
-#if MAC_INTERPOSE_FUNCTIONS
-  if (!asan_inited) return REAL(strdup)(s);
-#endif
+  if (!asan_inited) return internal_strdup(s);
   ENSURE_ASAN_INITED();
   if (flags()->replace_str) {
     uptr length = REAL(strlen)(s);
=======================================================

Because internal_strdup() calls malloc(), it may hit an assertion within the ASan allocator.

Reported by ramosian.glider on 2012-10-26 10:23:53

ramosian-glider commented 9 years ago
Fixed in r166768

Reported by ramosian.glider on 2012-10-26 13:53:43

ramosian-glider commented 9 years ago
Adding Project:AddressSanitizer as part of GitHub migration.

Reported by ramosian.glider on 2015-07-30 09:13:40