[PATCH] D24454: [lsan] [aarch64] Fix calculating TLS area
    Strahinja Petrovic via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Mon Sep 12 06:15:08 PDT 2016
    
    
  
spetrovic created this revision.
spetrovic added reviewers: rengolin, peter.smith, zatrazz.
spetrovic added a subscriber: llvm-commits.
Herald added subscribers: kubabrecka, rengolin, aemerson.
This patch fixes calculating begin of TLS area. For example in pthread_setspecific function memory is allocated (calloc) and pointer on that memory is stored in TLS area, before this patch LSAN was skipping that part of TLS area (because begin of TLS area was not calculated correctly). Because of this memory leak was reported. I'm referencing on libc (# define THREAD_SELF \ ((struct pthread *)__builtin_thread_pointer () - 1)) in calculating begin of TLS area. This patch fixes make-check tests:  TestCases/use_tls_pthread_specific_dynamic.cc, use_tls_pthread_specific_static.cc.
https://reviews.llvm.org/D24454
Files:
  lib/sanitizer_common/sanitizer_linux_libcdep.cc
Index: lib/sanitizer_common/sanitizer_linux_libcdep.cc
===================================================================
--- lib/sanitizer_common/sanitizer_linux_libcdep.cc
+++ lib/sanitizer_common/sanitizer_linux_libcdep.cc
@@ -298,7 +298,10 @@
                 rdhwr %0,$29;\
                 .set pop" : "=r" (thread_pointer));
   descr_addr = thread_pointer - kTlsTcbOffset - TlsPreTcbSize();
-# elif defined(__aarch64__) || defined(__s390__)
+# elif defined(__aarch64__)
+  descr_addr = reinterpret_cast<uptr>(__builtin_thread_pointer()) -
+                                      ThreadDescriptorSize();
+# elif defined(__s390__)
   descr_addr = reinterpret_cast<uptr>(__builtin_thread_pointer());
 # elif defined(__powerpc64__)
   // PPC64LE uses TLS variant I. The thread pointer (in GPR 13)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24454.71000.patch
Type: text/x-patch
Size: 800 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160912/3bafa30f/attachment.bin>
    
    
More information about the llvm-commits
mailing list