forked from OSchip/llvm-project
tsan: work around known bug in libstdc++
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58066 llvm-svn: 202403
This commit is contained in:
parent
247eb8e52e
commit
46ebecc1fe
|
@ -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<uptr>(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<uptr>(ptr);
|
||||
dtls.last_memalign_size = size;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue