Date: Thu, 20 Dec 2018 12:59:06 +0400 From: Gleb Popov <arrowd@freebsd.org> To: freebsd-hackers <freebsd-hackers@freebsd.org> Subject: Calling a function from a SO breaks in libc Message-ID: <CALH631m4D-wNNYY-YwZ%2BvyNohiZ3sD3VpOQYDKihPnmEuBmCrw@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
When debugging software with GDB on FreeBSD 12+ I often get into following situation: (gdb) next (anonymous namespace)::D13AsmPrinter::EmitInstruction (this=0x8056b4b80, MI=0x805765690) at /home/arr/projects/d13/lib/Target/D13/D13AsmPrinter.cpp:152 152 EmitToStreamer(*OutStreamer, TmpInst); (gdb) step Now instead of entering into EmitStreamer(), I see: _thr_rtld_set_flag (mask=1) at /usr/src/lib/libthr/thread/thr_rtld.c:171 171 { Trying to get out of there: (gdb) finish Run till exit from #0 _thr_rtld_set_flag (mask=1) at /usr/src/lib/libthr/thread/thr_rtld.c:171 0x000000080027669b in thread_mask_set (mask=<optimized out>) at /usr/src/libexec/rtld-elf/rtld_lock.c:177 177 return lockinfo.thread_set_flag(mask); Value returned is $3 = 0 (gdb) finish Run till exit from #0 0x000000080027669b in thread_mask_set (mask=<optimized out>) at /usr/src/libexec/rtld-elf/rtld_lock.c:177 rlock_acquire (lock=0x800287ba0 <rtld_locks>, lockstate=0x7fffffff9608) at /usr/src/libexec/rtld-elf/rtld_lock.c:203 203 if (thread_mask_set(lock->mask) & lock->mask) { (gdb) finish Run till exit from #0 rlock_acquire (lock=0x800287ba0 <rtld_locks>, lockstate=0x7fffffff9608) at /usr/src/libexec/rtld-elf/rtld_lock.c:203 _rtld_bind (obj=0x80028b400, reloff=625152) at /usr/src/libexec/rtld-elf/rtld.c:808 808 if (sigsetjmp(lockstate.env, 0) != 0) (gdb) finish Run till exit from #0 _rtld_bind (obj=0x80028b400, reloff=625152) at /usr/src/libexec/rtld-elf/rtld.c:808 _rtld_bind_start () at /usr/src/libexec/rtld-elf/amd64/rtld_start.S:124 124 movq %rax,0x60(%rsp) # Store target over reloff argument Value returned is $4 = 34402603952 (gdb) finish Run till exit from #0 _rtld_bind_start () at /usr/src/libexec/rtld-elf/amd64/rtld_start.S:124 Program received signal SIGTRAP, Trace/breakpoint trap. _rtld_bind_start () at /usr/src/libexec/rtld-elf/amd64/rtld_start.S:155 155 ret # "Return" to target address (gdb) finish Run till exit from #0 _rtld_bind_start () at /usr/src/libexec/rtld-elf/amd64/rtld_start.S:155 Program received signal SIGTRAP, Trace/breakpoint trap. 0x00000008028e13b4 in llvm::AsmPrinter::EmitToStreamer (this=0x80028b400, S=..., Inst=...) at /home/arr/projects/d13/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:228 After this. the debugging is impossible, because every "cont/step/next" command yields "Program received signal SIGTRAP, Trace/breakpoint trap". Trying to "print" anything causes GDB to crash. It should be noted, that I'm linking to LLVM-7.so library. Using static linkage for the executable I'm debugging makes this bug go away. Anyone have an idea what's going on and how to fix that?
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CALH631m4D-wNNYY-YwZ%2BvyNohiZ3sD3VpOQYDKihPnmEuBmCrw>