[llvm-bugs] [Bug 50936] New: lldb step over glibc dlopen fails (__GI__dl_catch_exception or runs away)
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Jun 29 16:44:21 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50936
Bug ID: 50936
Summary: lldb step over glibc dlopen fails
(__GI__dl_catch_exception or runs away)
Product: lldb
Version: 12.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: All Bugs
Assignee: lldb-dev at lists.llvm.org
Reporter: rprichard at google.com
CC: jdevlieghere at apple.com, llvm-bugs at lists.llvm.org
Using glibc (specifically gLinux aka Debian), LLDB is unable to step over
certain dlopen calls.
In one situation, the library was part of the initial set of needed DSOs, and
LLDB fails with a __GI__dl_catch_exception error. In another situation, the
library isn't loaded already, and when dlopen loads it, LLDB fails to stop
after the dlopen call (and runs to process exit).
Both problems reproduce with either LLVM 12.0.0
(clang+llvm-12.0.0-x86_64-linux-gnu-ubuntu-20.04) or with an upstream Clang and
LLDB that I built today from origin/main.
Test case:
$ cat >test.c <<EOF
#include <dlfcn.h>
int main(void) {
void* ptr;
dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL | RTLD_NOLOAD);
dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL | RTLD_NOLOAD);
dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL | RTLD_NOLOAD);
dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL);
dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL);
dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL);
return 0;
}
EOF
## Situation 1: __GI__dl_catch_exception (link with -lm)
$ /x/clang12/bin/clang -g test.c -ldl -lm
$ /x/clang12/bin/lldb a.out
(lldb) target create "a.out"
Current executable set to '/x/mess/a.out' (x86_64).
(lldb) b main
Breakpoint 1: where = a.out`main + 15 at test.c:4:3, address =
0x000000000040113f
(lldb) run
Process 282393 launched: '/x/mess/a.out' (x86_64)
Process 282393 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x000000000040113f a.out`main at test.c:4:3
1 #include <dlfcn.h>
2 int main(void) {
3 void* ptr;
-> 4 dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL | RTLD_NOLOAD);
5 dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL | RTLD_NOLOAD);
6 dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL | RTLD_NOLOAD);
7 dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL);
(lldb) n
Process 282393 stopped
* thread #1, name = 'a.out', stop reason = step over
frame #0: 0x00007ffff7dca260
libc.so.6`__GI__dl_catch_exception(exception=0x00007fffffffda40,
operate=0x00007ffff7fe5ca0, args=0x00007fffffffda60) at
dl-error-skeleton.c:209:18
## Situation 2: process runs away when dlopen loads libm.so.6 (don't link with
-lm)
$ /x/clang12/bin/clang -g test.c -ldl
$ /x/clang12/bin/lldb a.out
(lldb) target create "a.out"
Current executable set to '/x/mess/a.out' (x86_64).
(lldb) b test.c:5
Breakpoint 1: where = a.out`main + 35 at test.c:5:3, address =
0x0000000000401153
(lldb) run
Process 283170 launched: '/x/mess/a.out' (x86_64)
Process 283170 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x0000000000401153 a.out`main at test.c:5:3
2 int main(void) {
3 void* ptr;
4 dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL | RTLD_NOLOAD);
-> 5 dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL | RTLD_NOLOAD);
6 dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL | RTLD_NOLOAD);
7 dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL);
8 dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL);
(lldb) n
Process 283170 stopped
* thread #1, name = 'a.out', stop reason = step over
frame #0: 0x0000000000401167 a.out`main at test.c:6:3
3 void* ptr;
4 dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL | RTLD_NOLOAD);
5 dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL | RTLD_NOLOAD);
-> 6 dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL | RTLD_NOLOAD);
7 dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL);
8 dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL);
9 dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL);
(lldb) n
Process 283170 stopped
* thread #1, name = 'a.out', stop reason = step over
frame #0: 0x000000000040117b a.out`main at test.c:7:3
4 dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL | RTLD_NOLOAD);
5 dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL | RTLD_NOLOAD);
6 dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL | RTLD_NOLOAD);
-> 7 dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL);
8 dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL);
9 dlopen("libm.so.6", RTLD_NOW | RTLD_LOCAL);
10 return 0;
(lldb) n
Process 283170 exited with status = 0 (0x00000000)
--
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/20210629/9f47e4bb/attachment.html>
More information about the llvm-bugs
mailing list