https://github.com/vitalybuka created https://github.com/llvm/llvm-project/pull/228930
Starting with glibc 2.34, failed dlfcn calls store a per-thread error struct in TLS (__libc_dlerror_result) instead of a pthread_key_t, and free it in __libc_thread_freeres() after all pthread TSD destructors have completed. Because ASan, LSan, and HWASan unregister the exiting thread in their pthread TSD destructors during __nptl_deallocate_tsd(), LSan stops scanning that thread's TLS before __libc_thread_freeres() frees __libc_dlerror_result. If a leak check runs in that window (for example, when the main thread exits while a detached worker thread is finishing) and libc debug symbols are not installed to match the default *dlerror* suppression on _dlerror_run, LSan reports a false positive leak from dlsym/dlopen. Call `if (dlerror()) dlerror();` before unregistering the exiting thread so glibc frees its per-thread dlerror buffer while the thread is still tracked. Assisted-by: Gemini _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
