#579021 gdb fails with Cannot find new threads: generic error when linking with libdbi

Package:
gdb
Source:
gdb
Description:
GNU Debugger
Submitter:
Craig Small
Date:
2011-11-24 02:21:04 UTC
Severity:
normal
#579021#5
Date:
2010-04-24 12:07:59 UTC
From:
To:
I had one program I'm writing and started getting these strange gdb
errors, I narrowed it down to linking with libdbi. This is the problem I
see:

csmall@elmo:~$ cat test.c
#include <stdio.h>
#include <dbi/dbi.h>

int main(int argc, char *argv[])
{
  printf("Hello, World!\n");
  dbi_initialize(NULL);
  return 0;
}
csmall@elmo:~$ gcc -ggdb -o test test.c -ldbi
csmall@elmo:~$ gdb ./test
GNU gdb (GDB) 7.1-debian
Copyright (C) 2010 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".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/csmall/test...done.
(gdb) run
Starting program: /home/csmall/test
Hello, World!
[Thread debugging using libthread_db enabled]
Cannot find new threads: generic error
(gdb) n
Cannot execute this command while the selected thread is running.
(gdb) info threads
Cannot find new threads: generic error

#579021#10
Date:
2010-04-26 01:19:26 UTC
From:
To:
Hello,
  I had a closer look at programs using libdbi.  Most of them seem to
link to libpthread. Programs such as rrdtool and syslog-ng use it.

So I changed my command line to build my simple test program I
sent in my initial report from:
   gcc -o test -ldbi -ggdb test.c
 to:
   gcc -o test -ldbi -lpthread -ggdb test.c

GDB now works as you expect, info threads sees threads and all is well.
The question is, should gdb work fine without the program having to
link to libpthread? Or is there a problem in libdbi?

I built my own libdbi 0.8.3 just in case it was a problem with 0.8.2
but get the same results.

 - Craig

#579021#15
Date:
2010-05-03 12:33:10 UTC
From:
To:
Does libdbi load libpthread dynamically?
#579021#20
Date:
2010-05-04 10:56:09 UTC
From:
To:
Indirectly it does.
libdbi uses database-specific backends.
So, for example, libdbd-mysql.so is dlopen()ed by libdbi and that mysql
specific library is dynamically linked to libpthread.

 - Craig

#579021#25
Date:
2010-05-04 17:08:02 UTC
From:
To:
OK, thanks.  That's going to be the issue then; I'm surprised to see
it resurface, but GDB has historically had trouble in this situation.

#579021#30
Date:
2011-11-24 01:46:29 UTC
From:
To:

#579021#35
Date:
2011-11-24 02:13:05 UTC
From:
To:
And with

  LD_PRELOAD=/lib/x86_64-linux-gnu/libpthread.so.0 gdb sudo

this suddenly starts to work. (Why is it that I only need this kludge
on Debian? openSUSE also ships gdb 7.3)