Description of problem: There appears to be a deadlock in libasan when a library calling `textdomain(3)` pre-loads libasan via $LD_PRELOAD. I noticed this when extending our systemd integration test suite under ASan/UBSan[0], as `textdomain()` is used by procps-ng utils (ps, pidof, pkill, ...). These utilities are linked against libsystemd.so, so the $LD_PRELOAD is necessary in such cases (if systemd is built with ASan), rendering the tests broken. This issue is reproducible with libasan from both clang and gcc on Rawhide. [0] https://github.com/systemd/systemd/pull/23741#issuecomment-1158704791 Version-Release number of selected component (if applicable): compiler-rt-14.0.0-1.fc37.x86_64 Steps to Reproduce: # LD_PRELOAD=/usr/lib64/clang/14.0.0/lib/libclang_rt.asan-x86_64.so ps --help # LD_PRELOAD=/usr/lib64/clang/14.0.0/lib/libclang_rt.asan-x86_64.so ltrace -- ps --help Actual results: The first call simply hangs. Subsequent ltrace shows that the ps utility is stuck on the `textdomain()` call: ``` # LD_PRELOAD=/usr/lib64/clang/14.0.0/lib/libclang_rt.asan-x86_64.so ltrace -- ps --help __cxa_atexit(0x564ac8a48d70, 0, 0x564ac8a50f80, 0x564ac8a50f78) = 0 strrchr("ps", '/') = nil setlocale(LC_ALL, "") = "C.UTF-8" bindtextdomain("procps-ng", "/usr/share/locale") = "/usr/share/locale" textdomain("procps-ng" ``` Similar thing can be observed with other utils, like pidof: ``` # LD_PRELOAD=/usr/lib64/clang/14.0.0/lib/libclang_rt.asan-x86_64.so ltrace -- pidof bash setlocale(LC_ALL, "") = "C.UTF-8" bindtextdomain("procps-ng", "/usr/share/locale") = "/usr/share/locale" textdomain("procps-ng" ``` Expected results: In this specific case, ps should simply dump its help message: ``` # ps --help Usage: ps [options] Try 'ps --help <simple|list|output|threads|misc|all>' or 'ps --help <s|l|o|t|m|a>' for additional help text. For more details see ps(1). ``` Additional info: This issue appears to be reported several times on multiple places, without any resolution: [1] https://bugzilla.redhat.com/show_bug.cgi?id=1716928 [2] https://github.com/llvm/llvm-project/issues/49223 [3] https://sourceware.org/bugzilla/show_bug.cgi?id=27653
Tentative patch submitted upstream: https://reviews.llvm.org/D128992
This bug appears to have been reported against 'rawhide' during the Fedora Linux 37 development cycle. Changing version to 37.
The aforementioned patch has since landed, and I've confirmed that "LD_PRELOAD=/usr/lib64/clang/15.0.6/lib/libclang_rt.asan-x86_64.so ps --help" does work without hanging now.