[PATCH v3] nptl_db: Support different libpthread/ld.so load orders (bug 27744)

Szabolcs Nagy szabolcs.nagy@arm.com
Thu Apr 22 07:28:27 GMT 2021


The 04/21/2021 13:47, Florian Weimer via Libc-alpha wrote:
> * Florian Weimer via Libc-alpha:
> 
> > libthread_db is loaded once GDB encounters libpthread, and at this
> > point, ld.so may not have been processed by GDB yet. As a result,
> > _rtld_global cannot be accessed by regular means from libthread_db.
> > To make this work until GDB can be fixed, acess _rtld_global through
> > a pointer stored in libpthread.
> >
> > The new test does not reproduce bug 27744 with
> > --disable-hardcoded-path-in-tests, but is still a valid smoke test.
> > With --enable-hardcoded-path-in-tests, it is necessary to avoid
> > add-symbol-file because this can tickle a GDB bug.
> >
> > Fixes commit 1daccf403b1bd86370eb94edca794dc106d02039 ("nptl: Move
> > stack list variables into _rtld_global").
> >
> > ---
> > v3: Mark test as UNSUPPORTED if launching gdb fails with ENOENT.
> >     This is the version I'd like to commit soon.
> 
> I've pushed this version given that Pedro acknowledged v2.

on the aarch64 buildbot i see

FAIL: nptl/tst-pthread-gdb-attach

$ cat nptl/tst-pthread-gdb-attach.out
+set debug libthread-db 1
+add-symbol-file /work/glibc-aarch64-linux/build/build/nptl/tst-pthread-gdb-attach
add symbol table from file "/work/glibc-aarch64-linux/build/build/nptl/tst-pthread-gdb-attach"
+set auto-load safe-path /work/glibc-aarch64-linux/build/build/nptl_db
+set libthread-db-search-path /work/glibc-aarch64-linux/build/build/nptl_db
+attach 461328
[New LWP 461329]
Trying host libthread_db library: /work/glibc-aarch64-linux/build/build/nptl_db/libthread_db.so.1.
td_ta_new failed: application not linked with libthread
thread_db_load_search returning 0
Trying host libthread_db library: /work/glibc-aarch64-linux/build/build/nptl_db/libthread_db.so.1.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/work/glibc-aarch64-linux/build/build/nptl_db/libthread_db.so.1".
thread_db_load_search returning 1
0x0000ffff96d3bb18 in __futex_abstimed_wait_common64 (futex_word=0xffff96cca210, expected=461329, clockid=<optimized out>, abstime=0x0, private=<optimized out>, cancel=cancel@entry=true) at futex-internal.c:74
74          err = INTERNAL_SYSCALL_CANCEL (futex_time64, futex_word, op, expected,
+break debugger_inspection_point
Breakpoint 1 at 0x1ea8: file tst-pthread-gdb-attach.c, line 76.
+continue
Timed out: killed the child process
Termination time: 2021-04-21T18:44:39.686118409
Last write to standard output: 2021-04-21T18:44:19.867449485



the test nptl/tst-pthread-gdb-attach-static passes:

$ cat nptl/tst-pthread-gdb-attach-static.out
+set debug libthread-db 1
+set auto-load safe-path /work/glibc-aarch64-linux/build/build/nptl_db
+set libthread-db-search-path /work/glibc-aarch64-linux/build/build/nptl_db
+attach 461347
[New LWP 461348]
Trying host libthread_db library: /work/glibc-aarch64-linux/build/build/nptl_db/libthread_db.so.1.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/work/glibc-aarch64-linux/build/build/nptl_db/libthread_db.so.1".
thread_db_load_search returning 1
0x0000000000419c40 in __futex_abstimed_wait_common64 (futex_word=0xffff94b08590, expected=461348, clockid=<optimized out>, abstime=0x0, private=<optimized out>, cancel=cancel@entry=true) at futex-internal.c:74
74          err = INTERNAL_SYSCALL_CANCEL (futex_time64, futex_word, op, expected,
+break debugger_inspection_point
Breakpoint 1 at 0x400720: file tst-pthread-gdb-attach.c, line 76.
+continue
[Switching to Thread 0xffff94b084c0 (LWP 461348)]

Thread 2 "tst-pthread-gdb" hit Breakpoint 1, debugger_inspection_point () at tst-pthread-gdb-attach.c:76
76      }
+thread 1
[Switching to thread 1 (Thread 0x828d000 (LWP 461347))]
#0  0x0000000000419c40 in __futex_abstimed_wait_common64 (futex_word=0xffff94b08590, expected=461348, clockid=<optimized out>, abstime=0x0, private=<optimized out>, cancel=cancel@entry=true) at futex-internal.c:74
74          err = INTERNAL_SYSCALL_CANCEL (futex_time64, futex_word, op, expected,
+print altered_by_debugger
$1 = 0
+print altered_by_debugger = 1
$2 = 1
+thread 2
[Switching to thread 2 (Thread 0xffff94b084c0 (LWP 461348))]
#0  debugger_inspection_point () at tst-pthread-gdb-attach.c:76
76      }
+print altered_by_debugger
$3 = 0
+print altered_by_debugger = 2
$4 = 2
+continue
[Thread 0xffff94b084c0 (LWP 461348) exited]
[Inferior 1 (process 461347) exited normally]


More information about the Gdb-patches mailing list