[all-commits] [llvm/llvm-project] f69342: Reland "[compiler-rt] [sanitizer_common] Fix SIGSE...
Mike Kruskal via All-commits
all-commits at lists.llvm.org
Tue Jul 14 12:24:10 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: f69342fa200100560c689e0ccdbbc5c3249aee4b
https://github.com/llvm/llvm-project/commit/f69342fa200100560c689e0ccdbbc5c3249aee4b
Author: Mike Kruskal <mkruskal at google.com>
Date: 2026-07-14 (Tue, 14 Jul 2026)
Changed paths:
M compiler-rt/lib/sanitizer_common/sanitizer_common_nolibc.cpp
M compiler-rt/lib/sanitizer_common/sanitizer_dl.cpp
M compiler-rt/lib/sanitizer_common/sanitizer_dl.h
M compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
M compiler-rt/lib/tsan/go/buildgo.sh
M compiler-rt/test/sanitizer_common/TestCases/Linux/dlopen_image_base.c
Log Message:
-----------
Reland "[compiler-rt] [sanitizer_common] Fix SIGSEGV in ForEachMappedRegion for DSOs with custom image base" (#209576)
Attempt 2 at #206299, fixing a linkage issue with gotsan on older
versions of glibc. Rather than forcing linkage of libdl (which may not
be safe with go), this just disables the dladdr usage under go builds.
This bug only affected MSAN and DFSAN anyway, and the code should be
unused by TSAN.
`ForEachMappedRegion` processes dynamic linker map entries to track
loaded segments. However, it assumes map->l_addr is the address of the
ELF header. For DSOs linked with a custom preferred image base offset
(e.g. -Wl,--image-base=0x4000000), `map->l_addr` contains the relocation
bias: `map->l_addr = actual_load_address - preferred_base`
In this case, map->l_addr points below the first loaded segment in
unmapped or PROT_NONE memory. Doing a read dereference at this address
triggers a SIGSEGV. Add a call to dladdr() on the dynamic section
pointer map->l_ld to obtain the true ELF header base address.
Likely fixes https://github.com/llvm/llvm-project/issues/84482 - which
looks like the exact same stacktrace I was debugging that led me to this
fix
Also looks it may have shown up in
https://github.com/llvm/llvm-project/issues/21068 - my case was also
flaky, and it only shows up if you build the so with custom base address
Assisted-by: Gemini
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list