[patch] Make _thread_db_sizeof_pthread public for Sanitizers
Carlos O'Donell
carlos@redhat.com
Fri Jan 1 13:36:40 GMT 2021
On 1/1/21 7:42 AM, Florian Weimer wrote:
> * Jan Kratochvil via Libc-alpha:
>
>> Sanitizers currently contain ugly list of glibc versions and their
>> sizeof(struct pthread).
>> https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp#L276
>>
>> This list is not much maintained causing SEGVs of Sanitizers:
>> $ echo 'int main(){}'|clang -g -fsanitize=leak -x c++ -;./a.out
>> Tracer caught signal 11: addr=0x7f1087f51f40 pc=0x4222c8 sp=0x7f1086effd40
>> ==234624==LeakSanitizer has encountered a fatal error.
>> ==234624==HINT: For debugging, try setting environment variable LSAN_OPTIONS=verbosity=1:log_threads=1
>> ==234624==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)
>>
>> I would find better if just glibc made the value public, Sanitizers can then
>> read it by dlsym():
>
> Do you know why the GetTLS function needs to know the size of the
> thread descriptor? And why it adds it to the start address of the TLS
> area, without subtracting it from the area size? I think this
> identifies the wrong memory region as TLS.
This also seems like a use case for GLIBC_DEBUG (available via dlsym,
with no copy relocs). However, like you, I'd like to know why the size
of the descriptor is needed (XY problem).
--
Cheers,
Carlos.
More information about the Libc-alpha
mailing list