dlpi_tls_data is incorrect NULL when dlpi_tls_modid>0

Fangrui Song i@maskray.me
Fri Apr 2 23:06:01 GMT 2021


I was trying to clean up llvm-project/compiler-rt sanitizers GetTls
function https://reviews.llvm.org/D98926 and my change was reverted
due to an annoying Ubuntu 16.04 glibc 2.23 bug (seem so on both amd64
and ppc64le)
dlpi_tls_data is incorrect NULL when dlpi_tls_modid>0.

Thread 1 "tls_race.cpp.tm" hit Breakpoint 6,
__sanitizer::CollectStaticTlsRanges (info=0x7fffffffe8d0, size=64,
data=0x7fffffffe9d0) at
/tmp/llvm/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp:294
294       if (!info->dlpi_tls_data)
(gdb) p *info
$5 = {dlpi_addr = 0, dlpi_name = 0x7ffff7ffe6f8 "", dlpi_phdr =
0x400040, dlpi_phnum = 10, dlpi_adds = 10, dlpi_subs = 0,
dlpi_tls_modid = 1, dlpi_tls_data = 0x0}

This works fine on glibc 2.31.

# dlpi_tls_data != NULL when dlpi_tls_modid>0
$1 = {dlpi_addr = 0, dlpi_name = 0x7ffff7ffe720 "", dlpi_phdr =
0x400040, dlpi_phnum = 12, dlpi_adds = 10, dlpi_subs = 0,
dlpi_tls_modid = 1, dlpi_tls_data = 0x7ffff7a35740}

So do people know when the bug was fixed? From the file log the
info.dlpi_tls_data assignment code hasn't changed since 2011-09.

commit 74718d13e4638ccc5922c2197b9088ff5fc00251
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Fri Sep 9 06:43:43 2011

    Fill in real information in __dl_iterate_phdr


More information about the Libc-alpha mailing list