I am using CentOS. I didn't set up the server and the environment is quite old.
I tried to debug a multithreaded server program and some error showed up.
Starting program: ./battle
Trying host libthread_db library: libthread_db.so.1.
Host libthread_db.so.1 resolved to: /lib64/libthread_db.so.1.
td_ta_new failed: application not linked with libthread
thread_db_load_search returning 0
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
Trying host libthread_db library: libthread_db.so.1.
Host libthread_db.so.1 resolved to: /lib64/libthread_db.so.1.
td_ta_new failed: versions of libpthread and libthread_db do not match
Trying host libthread_db library: /lib64/libthread_db.so.1.
td_ta_new failed: versions of libpthread and libthread_db do not match
thread_db_load_search returning 0
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
Then I realize that the problem is that the version of libpthread
shared library I link doesn't match the version of libthread_db
shared library which gdb
uses when debugging.
I read these 2 related questions Unable to Debug Multi-Threaded Application with gdb, GDB debugging warnings .
Then I tried to figure out what version of each is by using file
command (Please tell me if using file
to check the differences is correct. Anyway, I found some differences.)
ldd battle
linux-vdso.so.1 (0x00007fffcafff000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f390c675000)
.........
ls -l libpthread*
-rwxr-xr-x 1 root root 143280 Apr 9 2019 libpthread-2.12.so
-rwxr-xr-x 1 root root 806517 Dec 2 2018 libpthread-2.17.so
lrwxrwxrwx 1 root root 18 Jul 29 07:35 libpthread.so.0 -> libpthread-2.17.so
ls -l libthread_db*
-rwxr-xr-x 1 root root 34488 Apr 9 2019 libthread_db-1.0.so
lrwxrwxrwx 1 root root 19 Jul 29 07:35 libthread_db.so.1 -> libthread_db-1.0.so
file libpthread-2.17.so
libpthread-2.17.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped
file libthread_db-1.0.so
libthread_db-1.0.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped
file libpthread-2.12.so
libpthread-2.12.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped
So my progam is linked to libpthread-2.17.so
, which is for for GNU/Linux 2.6.16
, and gdb
uses libthread_db-1.0.so
, which is for for GNU/Linux 2.6.18
, mismatch? (Well I am not sure if I can compare them based on this information, can I?)
Does it mean that now I need to download a libthread_db-1.0.so
which is for for GNU/Linux 2.6.16
and link libthread_db.so.1
to it? Where can I download it from?
By the way, I also feel strange that for libpthread-2.17.so
and libpthread-2.12.so
on my server , 2.17 > 2.12
, the former should be a newer version. But it's for a lower Linux version (2.6.16
), maybe someone just copy it and rename the file? I don't know. :(