[PATCH] D26404: [asan/win] Add init hooks to .CRT$XLAB

Etienne Bergeron via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 8 11:20:48 PST 2016


etienneb added a comment.

I tried the patch and it's not solving the bug I was facing.

see: https://llvm.org/bugs/show_bug.cgi?id=30903

  =================================================================
  ==8172==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x01bdb6529fd0 in thread T0
      #0 0x7ff63f667aa4  (C:\src\llvm\ninja64\projects\compiler-rt\lib\asan\tests\default\Asan-x86_64-inline-Noinst-Test.exe+0x140047aa4)
      #1 0x7ff8c3a2b7fb  (C:\Windows\System32\ucrtbase.dll+0x18000b7fb)
      #2 0x7ff8c6cc7ec7  (C:\Windows\SYSTEM32\ntdll.dll+0x180007ec7)
      #3 0x7ff8c6cc7fb5  (C:\Windows\SYSTEM32\ntdll.dll+0x180007fb5)
      #4 0x7ff8c6cc7d93  (C:\Windows\SYSTEM32\ntdll.dll+0x180007d93)
      #5 0x7ff8c68ece69  (C:\Windows\System32\KERNEL32.DLL+0x18001ce69)
      #6 0x7ff63f6f3143  (C:\src\llvm\ninja64\projects\compiler-rt\lib\asan\tests\default\Asan-x86_64-inline-Noinst-Test.exe+0x1400d3143)
      #7 0x7ff63f6f3083  (C:\src\llvm\ninja64\projects\compiler-rt\lib\asan\tests\default\Asan-x86_64-inline-Noinst-Test.exe+0x1400d3083)
      #8 0x7ff63f6a8242  (C:\src\llvm\ninja64\projects\compiler-rt\lib\asan\tests\default\Asan-x86_64-inline-Noinst-Test.exe+0x140088242)
      #9 0x7ff8c68d8363  (C:\Windows\System32\KERNEL32.DLL+0x180008363)
      #10 0x7ff8c6d25e90  (C:\Windows\SYSTEM32\ntdll.dll+0x180065e90)
  
  Address 0x01bdb6529fd0 is a wild pointer.
  SUMMARY: AddressSanitizer: bad-free (C:\src\llvm\ninja64\projects\compiler-rt\lib\asan\tests\default\Asan-x86_64-inline-Noinst-Test.exe+0x140047aa4)
  ==8172==ABORTING



================
Comment at: lib/asan/asan_win.cc:358
+#pragma section(".CRT$XLAB", long, read)  // NOLINT
+__declspec(allocate(".CRT$XLAB")) void (NTAPI *__asan_tls_init)(
+    void *, unsigned long, void *) = asan_thread_init;
----------------
nit: to be consitant with line 346-347 should be indented that way:

__declspec(allocate(".CRT$XLAB"))
void (NTAPI *__asan_tls_init)( void *, unsigned long, void *) = asan_thread_init;


================
Comment at: lib/asan/asan_win_dynamic_runtime_thunk.cc:74
 int (*__asan_initialize_cloned_variables)() = InitializeClonedVariables;
+__declspec(allocate(".CRT$XLAB")) void (NTAPI *__asan_tls_init)(
+    void *, unsigned long, void *) = asan_thread_init;
----------------
ditto


================
Comment at: test/asan/TestCases/Windows/tls_init.cc:19
+my_thread_callback(PVOID module, DWORD reason, PVOID reserved) {
+  ran_before_main = true;
+  static const char str[] = "my_thread_callback\n";
----------------
this should be after line 24.
The behavior will be the same.


https://reviews.llvm.org/D26404





More information about the llvm-commits mailing list