From 46ebecc1fea39ce400444c8a24a209d4aaa89e27 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 27 Feb 2014 14:43:31 +0000 Subject: [PATCH] tsan: work around known bug in libstdc++ http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58066 llvm-svn: 202403 --- .../sanitizer_tls_get_addr.cc | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cc b/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cc index b3ffa8c70b78..d98640e1f00c 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cc @@ -75,21 +75,26 @@ void DTLS_on_tls_get_addr(void *arg_void, void *res) { return; uptr tls_size = 0; uptr tls_beg = reinterpret_cast(res) - arg->offset; - VPrintf(2, "__tls_get_addr: %p {%p,%p} => %p; tls_beg: %p; sp: %p\n", arg, - arg->dso_id, arg->offset, res, tls_beg, &tls_beg); + // Don't do anything fancy in this function, in particular don't print. + // Some versions of libstdc++ are miscompiled and call this function + // with mis-aligned stack: + // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58066 + // Printf uses SSE instructions that crash with mis-aligned accesses. + // VPrintf(2, "__tls_get_addr: %p {%p,%p} => %p; tls_beg: %p; sp: %p\n", arg, + // arg->dso_id, arg->offset, res, tls_beg, &tls_beg); if (dtls.last_memalign_ptr == tls_beg) { tls_size = dtls.last_memalign_size; - VPrintf(2, "__tls_get_addr: glibc <=2.18 suspected; tls={%p,%p}\n", tls_beg, - tls_size); + // VPrintf(2, "__tls_get_addr: glibc <=2.18 suspected; tls={%p,%p}\n", + // tls_beg, tls_size); } else if ((tls_beg % 4096) == sizeof(Glibc_2_19_tls_header)) { // We may want to check gnu_get_libc_version(). Glibc_2_19_tls_header *header = (Glibc_2_19_tls_header *)tls_beg - 1; tls_size = header->size; tls_beg = header->start; - VPrintf(2, "__tls_get_addr: glibc >=2.19 suspected; tls={%p %p}\n", tls_beg, - tls_size); + //VPrintf(2, "__tls_get_addr: glibc >=2.19 suspected; tls={%p %p}\n", + // tls_beg, tls_size); } else { - VPrintf(2, "__tls_get_addr: Can't guess glibc version\n"); + //VPrintf(2, "__tls_get_addr: Can't guess glibc version\n"); // This may happen inside the DTOR of main thread, so just ignore it. tls_size = 0; } @@ -98,7 +103,7 @@ void DTLS_on_tls_get_addr(void *arg_void, void *res) { } void DTLS_on_libc_memalign(void *ptr, uptr size) { - VPrintf(2, "DTLS_on_libc_memalign: %p %p\n", ptr, size); + // VPrintf(2, "DTLS_on_libc_memalign: %p %p\n", ptr, size); dtls.last_memalign_ptr = reinterpret_cast(ptr); dtls.last_memalign_size = size; }