[sanitizer] Don't call dlerror() after swift_demangle lookup through dlsym
authorserge-sans-paille <sguelton@redhat.com>
Tue, 12 Jul 2022 20:05:57 +0000 (22:05 +0200)
committerserge-sans-paille <sguelton@redhat.com>
Tue, 19 Jul 2022 07:07:30 +0000 (09:07 +0200)
Because the call to `dlerror()` may actually want to print something, which turns into a deadlock
as showcased in #49223.

Instead rely on further call to dlsym to clear `dlerror` internal state if they
need to check the return status.

Differential Revision: https://reviews.llvm.org/D128992

compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp

index 8be7709..b223f6c 100644 (file)
@@ -72,7 +72,6 @@ static swift_demangle_ft swift_demangle_f;
 // symbolication.
 static void InitializeSwiftDemangler() {
   swift_demangle_f = (swift_demangle_ft)dlsym(RTLD_DEFAULT, "swift_demangle");
-  (void)dlerror(); // Cleanup error message in case of failure
 }
 
 // Attempts to demangle a Swift name. The demangler will return nullptr if a