[llvm-bugs] [Bug 49879] New: linux command will be deadlock when linked with libasan

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Apr 7 05:05:20 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=49879

            Bug ID: 49879
           Summary: linux command will be deadlock when linked with
                    libasan
           Product: compiler-rt
           Version: 10.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: asan
          Assignee: unassignedbugs at nondot.org
          Reporter: hndxvon at 163.com
                CC: llvm-bugs at lists.llvm.org

Hello,
centos seems to be incompatible with libasan(8.0.1).
Run a linux command(like ps,free) with LD_PRELOAD envrionable variable on
centos aarch64 kunpeng920 (gcc-9.2/glibc-2.30), 
It will locked.

Run my scripts:
export ASAN_OPTIONS=detect_leaks=0:halt_on_error=0
export LD_LIBRARY_PATH=/usr/lib64/clang/8.0.1/lib/
export LD_PRELOAD=/lib64/clang/8.0.1/lib/libclang_rt.asan-aarch64.so
ps

------------------------------------------------------------------------
(gdb) bt
#0  0x0000ffffb244ecd8 in pthread_rwlock_wrlock () from /lib64/libpthread.so.0
#1  0x0000ffffb279501c in textdomain () from /lib64/libc.so.6
#2  0x0000ffffb29f72a0 in __interceptor_textdomain (domainname=0x40cab8
"procps-ng") at
../lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:413
#3  0x0000000000402b10 in main ()
(gdb) info threads
  Id   Target Id                              Frame
* 1    Thread 0xffffb2126480 (LWP 25205) "ps" 0x0000ffffb279501c in textdomain
() from /lib64/libc.so.6
There is only one thread. how could it generate deadlock?

But unset LD_PRELOAD, ps runs ok.
Try update compiler-rt to 10.0.0, this deadlock still exists.


Then I encountered a detailed stack of deadlock, such as:
The ASAN runtime calls dlerror (which uses gettext) during init, which causes a
deadlock.

#0  __dcigettext (domainname=0xfffff73fb1e8 <_libc_intl_domainname> "libc", 
    msgid1=0xfffff3b01ea0 "undefined symbol: swift_demangle", 
    msgid2=msgid2 at entry=0x0, plural=plural at entry=0, n=n at entry=0, 
    category=category at entry=5) at dcigettext.c:485
#1  0x0000fffff72f6068 in __GI___dcgettext (domainname=<optimized out>, 
    msgid=<optimized out>, category=category at entry=5) at dcgettext.c:47
#2  0x0000fffff7450b48 in __dlerror () at dlerror.c:102
#3  0x0000fffff7588ccc in AsanInitInternal ()
    at ../projects/compiler-rt/lib/asan/asan_rtl.cpp:521
#4  0x0000fffff7580698 in __interceptor_malloc ()
    at ../projects/compiler-rt/lib/asan/asan_malloc_linux.cpp:144
#5  0x0000fffff72f5d58 in set_binding_values (
    domainname=0xfffff6c21290 "libgpg-error", dirnamep=0xffffffffefb8, 
    codesetp=0x0) at bindtextdom.c:202
#6  0x0000fffff72f5fcc in set_binding_values (codesetp=0x0, 
    dirnamep=0xffffffffefb8, domainname=<optimized out>) at bindtextdom.c:82
#7  __bindtextdomain (domainname=<optimized out>, dirname=<optimized out>)
    at bindtextdom.c:320
#8  0x0000fffff6c0c860 in gpg_err_init () from /usr/lib64/libgpg-error.so.0
#9  0x0000fffff7fcc630 in call_init (l=<optimized out>, argc=argc at entry=1, 
    argv=argv at entry=0xfffffffff068, env=env at entry=0xfffffffff078)
    at dl-init.c:74
#10 0x0000fffff7fcc72c in call_init (env=0xfffffffff078, argv=0xfffffffff068, 
    argc=1, l=<optimized out>) at dl-init.c:37
#11 _dl_init (main_map=0xfffff7fff280, argc=1, argv=0xfffffffff068, 
    env=0xfffffffff078) at dl-init.c:121
#12 0x0000fffff7fbee08 in _dl_start_user () from /lib/ld-linux-aarch64.so.1


Thank you for helping.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210407/3e9f878f/attachment.html>


More information about the llvm-bugs mailing list