1

I tried to run gdb on keepassxc, but encountered an unfamiliar error:

$ gdb /usr/bin/keepassxc
GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/keepassxc...Reading symbols from /usr/lib/debug/.build-id/80/9b2f2d5157a8872dcd140977ba01adfca0e7ad.debug...done.
done.
(gdb) run
Starting program: /usr/bin/keepassxc 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Cannot find user-level thread for LWP 15111: generic error
(gdb) quit

The GDB FAQ gives some common causes for errors like "Cannot find user-level thread for LWP 15111: generic error" (the number after LWP is different each time):

9. GDB reports "Cannot find user-level thread for LWP 23957: generic error", how do I fix this?

There are several common causes:

  • You have a mismatch between libthread_db.so.1 and libpthread.so.0 (this most often happens when you have multiple installations of glibc, or when you debug a program on remote target, and host and target have different glibc versions).

  • You are using 64-bit debugger to debug 32-bit program, and your kernel has a 32-bit ptrace emulation bug. FIXME: add reference to specific kernel fix.

This has also been known to happen when one of DOSEMU's signal handlers is invoked from DPMI context, where the $gs register has a value different from what GDB and/or libthread_db.so.0 expect; SamuelBronson found running the program under gdbserver to alleviate the problem, at least with version 6.8.50.20090620-cvs on i386.

https://sourceware.org/gdb/wiki/FAQ

I am running a 64-bit machine with i386 enabled:

$ getconf LONG_BIT
64
$ dpkg --print-foreign-architectures
i386
$ dlocate libthread_db.so.1
libc6-i386: /lib32/libthread_db.so.1
libc6:i386: /lib/i386-linux-gnu/libthread_db.so.1
libc6:amd64: /lib/x86_64-linux-gnu/libthread_db.so.1
$ dlocate libpthread.so.0
libc6-i386: /lib32/libpthread.so.0
libc6:i386: /lib/i386-linux-gnu/libpthread.so.0
libc6:amd64: /lib/x86_64-linux-gnu/libpthread.so.0

and keepassxc does use libpthread.so.0:

$ ldd /usr/bin/keepassxc | grep thread
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f889b803000)

but so does texstudio:

$ ldd /usr/bin/texstudio | grep thread
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007efd2a09e000)

and I can load texstudio just fine.

$ gdb /usr/bin/texstudio 
GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/texstudio...Reading symbols from /usr/lib/debug/.build-id/8c/49a9b8c208b2b75fbd3dc0ad9d9bf009886a47.debug...done.
done.
(gdb) run
Starting program: /usr/bin/texstudio 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffe915a700 (LWP 20816)]
[New Thread 0x7fffda55f700 (LWP 20822)]
[New Thread 0x7fffcb7e9700 (LWP 20823)]
[New Thread 0x7fffca2fe700 (LWP 20824)]
[New Thread 0x7fffc96d9700 (LWP 20825)]
[New Thread 0x7fffc0937700 (LWP 20826)]
[Thread 0x7fffc0937700 (LWP 20826) exited]
[Thread 0x7fffc96d9700 (LWP 20825) exited]
[Thread 0x7fffca2fe700 (LWP 20824) exited]
[Thread 0x7fffe915a700 (LWP 20816) exited]
[Thread 0x7fffcb7e9700 (LWP 20823) exited]
[Thread 0x7fffda55f700 (LWP 20822) exited]
[Inferior 1 (process 20796) exited normally]
(gdb) quit

Furthermore, keepassxc is a 64-bit executable:

$ file /usr/bin/keepassxc
/usr/bin/keepassxc: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/l, for GNU/Linux 3.2.0, BuildID[sha1]=809b2f2d5157a8872dcd140977ba01adfca0e7ad, stripped

The closest thing to any existing information I could find was this bug that the owner could not reproduce after a reboot (for what it's worth, I can reproduce after a reboot):

Segfault: new in version 2.0.2, Ubuntu MATE 16.04

Application segfaults/exits with a bus error, sometimes on launch, sometimes later.

This is a new development after updating to version 2.0.2.

Trying to launch with GDB produces:

Starting program: /usr/bin/keepassx
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Cannot find user-level thread for LWP 5299: generic error

https://bugs.launchpad.net/ubuntu/+source/keepassx/+bug/1752353

That's actually a bug in keepassx, not keepassxc, but I get the same behavior in both.

$ gdb /usr/bin/keepassx
GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/keepassx...(no debugging symbols found)...done.
(gdb) run
Starting program: /usr/bin/keepassx 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Cannot find user-level thread for LWP 14893: generic error

One debugging strategy I've found is to use set verbose on before running the executable. Here is the output in case that is of use:

Starting program: /usr/bin/keepassxc 
Using PIE (Position Independent Executable) displacement 0x555555554000 for "/usr/bin/keepassxc".
Reading symbols from /lib64/ld-linux-x86-64.so.2...Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/ld-2.27.so...done.
done.
Reading symbols from system-supplied DSO at 0x7ffff7ffa000...(no debugging symbols found)...done.
Reading in symbols for rtld.c...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libsodium.so.23...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libQt5Network.so.5...Reading symbols from /usr/lib/debug/.build-id/46/2cebeefa58e5ccff5415b007f6a24425f29ada.debug...done.
done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5...Reading symbols from /usr/lib/debug/.build-id/f2/5f1c8a72b396ac28a985f7297d3ba0ed6cd567.debug...done.
done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5...Reading symbols from /usr/lib/debug/.build-id/d2/9dfc2cdd3a3ae0e1110f0c87c2778c8998efbe.debug...done.
done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libykpers-1.so.1...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libzxcvbn.so.0...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libargon2.so.0...(no debugging symbols found)...done.
Reading symbols from /lib/x86_64-linux-gnu/libgcrypt.so.20...(no debugging symbols found)...done.
Reading symbols from /lib/x86_64-linux-gnu/libz.so.1...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libQt5DBus.so.5...Reading symbols from /usr/lib/debug/.build-id/06/31cf3ce1c914e12696428ca4ed84951f588f6e.debug...done.
done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5...Reading symbols from /usr/lib/debug/.build-id/fb/710113d79e6ddae5d5495d0721dfe1b70d5e82.debug...done.
done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libstdc++.so.6...Reading symbols from /usr/lib/debug/.build-id/57/0bf32e8698fce3bfacc4a8b010827f842d1dd6.debug...done.
done.
Registering libstdc++-v6 pretty-printer for /usr/lib/x86_64-linux-gnu/libstdc++.so.6 ...
Registering xmethod matcher '%s' with %s' ...
Registering xmethod matcher '%s' with %s' ...
Registering xmethod matcher '%s' with %s' ...
Registering xmethod matcher '%s' with %s' ...
Registering xmethod matcher '%s' with %s' ...
Registering xmethod matcher '%s' with %s' ...
Registering xmethod matcher '%s' with %s' ...
Registering xmethod matcher '%s' with %s' ...
Registering xmethod matcher '%s' with %s' ...
Registering xmethod matcher '%s' with %s' ...
Registering xmethod matcher '%s' with %s' ...
Registering xmethod matcher '%s' with %s' ...
Registering xmethod matcher '%s' with %s' ...
Registering xmethod matcher '%s' with %s' ...
Registering xmethod matcher '%s' with %s' ...
Reading symbols from /lib/x86_64-linux-gnu/libm.so.6...Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/libm-2.27.so...done.
done.
Reading symbols from /lib/x86_64-linux-gnu/libc.so.6...Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/libc-2.27.so...done.
done.
Reading symbols from /lib/x86_64-linux-gnu/libpthread.so.0...Reading symbols from /usr/lib/debug/.build-id/28/c6aade70b2d40d1f0f3d0a1a0cad1ab816448f.debug...done.
done.
Registering glibc-pthread-locks pretty-printer for /lib/x86_64-linux-gnu/libpthread.so.0 ...
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Reading symbols from /usr/lib/x86_64-linux-gnu/libGL.so.1...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libpng16.so.16...Reading symbols from /usr/lib/debug/.build-id/d5/32f2230c3c84289a0833fc0c1352aaac5892c6.debug...done.
done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libharfbuzz.so.0...(no debugging symbols found)...done.
Reading symbols from /lib/x86_64-linux-gnu/libgcc_s.so.1...Reading symbols from /usr/lib/debug/.build-id/41/bdc55c07d5e5b1d8ab38e2c19b1f535855e084.debug...done.
done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libnghttp2.so.14...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libidn2.so.0...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/librtmp.so.1...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libpsl.so.5...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libnettle.so.6...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libgnutls.so.30...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libyubikey.so.0...(no debugging symbols found)...done.
Reading symbols from /lib/x86_64-linux-gnu/libusb-1.0.so.0...(no debugging symbols found)...done.
Reading symbols from /lib/x86_64-linux-gnu/libjson-c.so.3...(no debugging symbols found)...done.
Reading symbols from /lib/x86_64-linux-gnu/libgpg-error.so.0...(no debugging symbols found)...done.
Reading symbols from /lib/x86_64-linux-gnu/libdbus-1.so.3...Reading symbols from /usr/lib/debug/.build-id/c1/63c9bb03410c4c05458a989a804ff527d4f63f.debug...done.
done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libicui18n.so.60...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libicuuc.so.60...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libdouble-conversion.so.1...(no debugging symbols found)...done.
Reading symbols from /lib/x86_64-linux-gnu/libdl.so.2...Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/libdl-2.27.so...done.
done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0...Reading symbols from /usr/lib/debug/.build-id/75/81e089260b8198caa28c2e16bd2353e7a62225.debug...done.
done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libGLX.so.0...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libGLdispatch.so.0...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libfreetype.so.6...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libgraphite2.so.3...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libunistring.so.2...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libhogweed.so.4...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libgmp.so.10...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libp11-kit.so.0...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libtasn1.so.6...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libkrb5.so.3...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libk5crypto.so.3...(no debugging symbols found)...done.
Reading symbols from /lib/x86_64-linux-gnu/libcom_err.so.2...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libkrb5support.so.0...(no debugging symbols found)...done.
Reading symbols from /lib/x86_64-linux-gnu/libresolv.so.2...Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/libresolv-2.27.so...done.
done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libsasl2.so.2...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libgssapi.so.3...(no debugging symbols found)...done.
Reading symbols from /lib/x86_64-linux-gnu/libudev.so.1...(no debugging symbols found)...done.
Reading symbols from /lib/x86_64-linux-gnu/libsystemd.so.0...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libicudata.so.60...(no debugging symbols found)...done.
Reading symbols from /lib/x86_64-linux-gnu/libpcre.so.3...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libX11.so.6...Reading symbols from /usr/lib/debug/.build-id/44/1896d78103c8cf264ba06687cd49c700a2c5b5.debug...done.
done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libffi.so.6...Reading symbols from /usr/lib/debug/.build-id/35/55b5f599c9787dfddbf9e8df6f706b9044d985.debug...done.
done.
Reading symbols from /lib/x86_64-linux-gnu/libkeyutils.so.1...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libheimntlm.so.0...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libkrb5.so.26...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libasn1.so.8...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libhcrypto.so.4...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libroken.so.18...(no debugging symbols found)...done.
Reading symbols from /lib/x86_64-linux-gnu/librt.so.1...Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/librt-2.27.so...done.
done.
Reading symbols from /lib/x86_64-linux-gnu/liblzma.so.5...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/liblz4.so.1...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libxcb.so.1...Reading symbols from /usr/lib/debug/.build-id/3d/49ac024ca8f7e36f5296a7d0d7f083ab1c8a62.debug...done.
done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libwind.so.0...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libheimbase.so.1...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libhx509.so.5...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libsqlite3.so.0...(no debugging symbols found)...done.
Reading symbols from /lib/x86_64-linux-gnu/libcrypt.so.1...Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/libcrypt-2.27.so...done.
done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libXau.so.6...(no debugging symbols found)...done.
Reading symbols from /usr/lib/x86_64-linux-gnu/libXdmcp.so.6...(no debugging symbols found)...done.
Reading symbols from /lib/x86_64-linux-gnu/libbsd.so.0...(no debugging symbols found)...done.
Cannot find user-level thread for LWP 17450: generic error
Current language:  auto
The current source language is "auto; currently c".

Version information:

$ apt-cache policy keepassx keepassxc gdb
keepassx:
  Installed: 2.0.3-1
  Candidate: 2.0.3-1
  Version table:
 *** 2.0.3-1 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
        100 /var/lib/dpkg/status
keepassxc:
  Installed: 2.3.1+dfsg.1-1
  Candidate: 2.3.1+dfsg.1-1
  Version table:
 *** 2.3.1+dfsg.1-1 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
        100 /var/lib/dpkg/status
gdb:
  Installed: 8.1-0ubuntu3
  Candidate: 8.1-0ubuntu3
  Version table:
 *** 8.1-0ubuntu3 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
        100 /var/lib/dpkg/status

My questions are:

  • Is this reproducible on other machines and versions of Ubuntu?

  • If so, is this a bug in gdb, a bug in both keepassx and keepassxc, a bug in libc-dbg, or somewhere else?

0 Answers0