diff options
| author | Benjamin Stott <Benjamin.Stott@sony.com> | 2025-11-12 10:39:30 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-12 10:39:30 +0000 |
| commit | 0ff0892470f51fc7e72831e91f3fe876dfe14a90 (patch) | |
| tree | 90c8c8e6bade78d73253dfcec0b22424430ae194 /clang/lib/CodeGen/CodeGenModule.cpp | |
| parent | 7eeae8e41d7827d84de12df7b5ecfab3058900cb (diff) | |
[Clang][CodeGen] Add disable_sanitizer_instrumentation attribute to multiversion resolvers (#167516)
- Fixes https://github.com/llvm/llvm-project/issues/163369
- Segmentation fault occurred because resolver was calling TSan
instrumentation functions (__tsan_func_entry, __tsan_func_exit) but as
the resolver is run by the dynamic linker at load time, TSan is not
initialized yet so the current thread pointer is null.
- This PR adds the DisableSanitizerInstrumentation attribute to the
multiversion function resolvers to avoid issues like this.
- Added regression test for TSan segfault.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index f303550c6429..08c66bdbbb9f 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -4938,6 +4938,11 @@ void CodeGenModule::setMultiVersionResolverAttributes(llvm::Function *Resolver, setDSOLocal(Resolver); + // The resolver must be exempt from sanitizer instrumentation, as it can run + // before the sanitizer is initialized. + // (https://github.com/llvm/llvm-project/issues/163369) + Resolver->addFnAttr(llvm::Attribute::DisableSanitizerInstrumentation); + // Set the default target-specific attributes, such as PAC and BTI ones on // AArch64. Not passing Decl to prevent setting unrelated attributes, // as Resolver can be shared by multiple declarations. |
