[PATCH] D14637: [tsan] Don't demangle names not starting with "_Z"

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 13 01:49:32 PST 2015


kubabrecka created this revision.
kubabrecka added reviewers: dvyukov, glider, kcc, samsonov.
kubabrecka added subscribers: llvm-commits, zaks.anna, ismailp.

I noticed that when a symbol is named just "x", it gets demangled to "long long".  On POSIX, AFAIK, mangled names always start with "_Z", so lets just require that.

http://reviews.llvm.org/D14637

Files:
  lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc
  test/tsan/Darwin/symbolizer-dladdr.cc

Index: test/tsan/Darwin/symbolizer-dladdr.cc
===================================================================
--- test/tsan/Darwin/symbolizer-dladdr.cc
+++ test/tsan/Darwin/symbolizer-dladdr.cc
@@ -3,10 +3,12 @@
 #include "../test.h"
 
 int GlobalData[10];
+long long x;
 
 void *Thread(void *a) {
   barrier_wait(&barrier);
   GlobalData[2] = 42;
+  x = 7;
   return 0;
 }
 
@@ -18,6 +20,7 @@
   pthread_t t;
   pthread_create(&t, 0, Thread, 0);
   GlobalData[2] = 43;
+  x = 8;
   barrier_wait(&barrier);
   pthread_join(t, 0);
 }
@@ -27,3 +30,5 @@
 // CHECK: addr=[[ADDR:0x[0-9,a-f]+]]
 // CHECK: WARNING: ThreadSanitizer: data race
 // CHECK: Location is global 'GlobalData' at [[ADDR]] ({{.*}}+0x{{[0-9,a-f]+}})
+// CHECK: WARNING: ThreadSanitizer: data race
+// CHECK: Location is global 'x' at {{.*}} ({{.*}}+0x{{[0-9,a-f]+}})
Index: lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc
===================================================================
--- lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc
+++ lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc
@@ -48,6 +48,9 @@
 
 // Attempts to demangle the name via __cxa_demangle from __cxxabiv1.
 const char *DemangleCXXABI(const char *name) {
+  if (name[0] != '_' || name[1] != 'Z')
+    return name;
+
   // FIXME: __cxa_demangle aggressively insists on allocating memory.
   // There's not much we can do about that, short of providing our
   // own demangler (libc++abi's implementation could be adapted so that


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14637.40117.patch
Type: text/x-patch
Size: 1508 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151113/c7cb1528/attachment.bin>


More information about the llvm-commits mailing list