[lsan] False leaks on glibc riscv64 since PR #120036: GetTls() no longer covers struct pthread
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
Research direction
Start in compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp and inspect GetTls() around the SANITIZER_FREEBSD and SANITIZER_RISCV64 guards, especially TlsPreTcbSize(). Use the Fedora riscv64 libcupsfilters failure as the reproduction context. Done means glibc riscv64 no longer reports the false leak and the cupsfilters test/build completes successfully.
Written by the indexing model from the issue text.
Description
I was working on identifying why a new test in libcupsfilters 2.2.1 fails on Fedora 45 riscv64
The build log is here:
https://riscv-kojipkgs.fedoraproject.org/koji/buildinfo?buildID=124037
(see FAIL: cupsfilters/test-pclm-overflow.sh)
It appears that PR #120036 converted an else if to a pre-processor macro so that the necessary code for riscv64/glibc only runs on FreeBSD
# elif SANITIZER_FREEBSD
*size += 128; // RTLD_STATIC_TLS_EXTRA
# if defined(__mips__) || defined(__powerpc64__) || SANITIZER_RISCV64
const uptr pre_tcb_size = TlsPreTcbSize();
*addr -= pre_tcb_size;
*size += pre_tcb_size;
...
This landed in LLVM, GCC 16, and GCC 15.2
LLVM: (https://github.com/llvm/llvm-project/commit/801b519dfd01)
GCC 16: (https://github.com/gcc-mirror/gcc/commit/5111ea055f5699ad47605890fb45af5c3db1de4f)
GCC 15 branch (for 15.2): (https://github.com/gcc-mirror/gcc/commit/80f7f229883f)
But using a Fedora 42 mock buildroot with GCC downgraded to 15.1 (from https://riscv-kojipkgs.fedoraproject.org/koji/buildinfo?buildID=3557) I was able to see the test pass and the build complete.
The behavior can probably be repaired with something like:
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -630,6 +630,9 @@
*size += 1664;
# elif SANITIZER_FREEBSD
*size += 128; // RTLD_STATIC_TLS_EXTRA
+# endif
+
+# if SANITIZER_GLIBC || SANITIZER_FREEBSD
# if defined(__mips__) || defined(__powerpc64__) || SANITIZER_RISCV64
const uptr pre_tcb_size = TlsPreTcbSize();
*addr -= pre_tcb_size;
- Dominant language
- LLVM
- Stars
- 40.6k
- Forks
- 18.7k
- Avg merge
- 18h 16m
- Merged PRs (30d)
- 417
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from llvm/llvm-project
-
website
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
llvm/llvm-project#224961 ·
-
lldb test-suite
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
llvm/llvm-project#224948 · 1 comment ·
-
mlir
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
llvm/llvm-project#224908 · 1 comment ·
-
libc
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
llvm/llvm-project#224587 · 2 comments · 1 assignee ·
-
HLSL
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
llvm/llvm-project#224413 ·
All issues in llvm/llvm-project
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
objectionary/eo#8869 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
EricSpencer00/Resilient#4824 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
objectionary/jeo-maven-plugin#1758 ·
-
generics
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100