Bug 314131 - GDB issues error when debugging multiple threads
Summary: GDB issues error when debugging multiple threads
Keywords:
Status: CLOSED DEFERRED
Alias: None
Product: Fedora
Classification: Fedora
Component: gdb
Version: 7
Hardware: i686
OS: Linux
low
medium
Target Milestone: ---
Assignee: Jan Kratochvil
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 239652
TreeView+ depends on / blocked
 
Reported: 2007-10-01 16:38 UTC by Tim Michals
Modified: 2008-01-15 22:56 UTC (History)
0 users

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2008-01-11 16:52:56 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Unsuccessful reproducibility logs .tar.gz. (48.57 KB, application/octet-stream)
2007-10-01 20:23 UTC, Jan Kratochvil
no flags Details

Description Tim Michals 2007-10-01 16:38:59 UTC
Description of problem:
I'm trying to debug simple multithreaded app and get the following error:
[Thread debugging using libthread_db enabled]
Cannot find new threads: generic error

Can set break points and trace as shown below.
(gdb) 
Here is the info..

GNU gdb Red Hat Linux (6.6-15.fc7rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) list
9       #include <iostream>
10
11      void helloworld(const char* who)
12      {
13          std::cout << who << "says, \"Hello World.\"" << std::endl;
14      }
15
16      int main()
17      {
18          boost::thread thrd(boost::bind(&helloworld, "Bob"));
(gdb) list
19          thrd.join();
20      }
21
(gdb) b main
Breakpoint 1 at 0x8048320: file ../helloworld.cpp, line 18.
(gdb) run
Starting program: /home/tcmichals/workspace/example/Debug/example
[Thread debugging using libthread_db enabled]
Cannot find new threads: generic error
(gdb) n
Single stepping until exit from function _start,
which has no line number information.
Cannot find user-level thread for LWP 3719: generic error
(gdb) n
Single stepping until exit from function _start,
which has no line number information.
Cannot find user-level thread for LWP 3719: generic error

The kernel version is:
Linux version 2.6.22.4-65.fc7 (kojibuilder.redhat.com)
(gcc v
ersion 4.1.2 20070502 (Red Hat 4.1.2-12)) #1 SMP Tue Aug 21 22:36:56 EDT
2007

Several posting on this issue i.e.
http://sourceware.org/ml/gdb/2007-08/msg00128.html 


Version-Release number of selected component (if applicable):
 2.6.22.4-65.fc7

How reproducible:
Very


Steps to Reproduce:
1. Using boost example, I can send it, but it is a simple program
9       #include <iostream>
10
11      void helloworld(const char* who)
12      {
13          std::cout << who << "says, \"Hello World.\"" << std::endl;
14      }
15
16      int main()
17      {
18          boost::thread thrd(boost::bind(&helloworld, "Bob"));
(gdb) list
19          thrd.join();
20      }

  
Actual results:
gdb displays this error, Cannot find new threads: generic error  

Expected results:
It should not display this error, gdb works, but I'm trying to understand this error


Additional info:
Posted report on GDB website http://sourceware.org/ml/gdb/2007-09/msg00274.html
 and they said it is a kernel/gdb issue...

Comment 1 Jan Kratochvil 2007-10-01 17:10:03 UTC
The bug reported at:
  http://sourceware.org/ml/gdb/2007-08/msg00128.html
is a different one - it is about x86_64 kernel vs. i386 debugger.
That would be a fixed Bug 247561 but I expect you have no 64-bit kernel.

(going to check the i586 kernel)


Comment 2 Tim Michals 2007-10-01 18:21:07 UTC
(In reply to comment #1)
> The bug reported at:
>   http://sourceware.org/ml/gdb/2007-08/msg00128.html
> is a different one - it is about x86_64 kernel vs. i386 debugger.
> That would be a fixed Bug 247561 but I expect you have no 64-bit kernel.
> 
> (going to check the i586 kernel)
> 
That is correct, just downloaded FC7, the did a CVS get on boost and created a
simple app and got this issue. If you want I can attach the binary and source
etc later in the day.


Comment 3 Jan Kratochvil 2007-10-01 20:23:28 UTC
Created attachment 212811 [details]
Unsuccessful reproducibility logs .tar.gz.

Sorry but not reproducible.
Linux version 2.6.22.4-65.fc7 (kojibuilder.phx.redhat.com)
(gcc version 4.1.2 20070502 (Red Hat 4.1.2-12)) #1 SMP Tue Aug 21 21:32:04 EDT
2007
kernel-2.6.22.4-65.fc7.i586
gdb-6.6-15.fc7.i386
glibc-2.6-4.i686
Compiled by:
  g++ -o helloworld helloworld.cpp -Wall -ggdb2 -pthread -lboost_thread 
Source from:
  boost_1_34_1.tar.gz
  boost_1_34_1/libs/thread/tutorial/helloworld.cpp

GNU gdb Red Hat Linux (6.6-15.fc7rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) start
Breakpoint 1 at 0x8048998: file helloworld.cpp, line 17.
Starting program: /root/jkratoch/redhat/state1/helloworld 
[Thread debugging using libthread_db enabled]
[New Thread -1208108832 (LWP 2764)]
[Switching to Thread -1208108832 (LWP 2764)]
main () at helloworld.cpp:17
17	    boost::thread thrd(&helloworld);
(gdb) c
Continuing.
Hello World!
[New Thread -1208112240 (LWP 2767)]
[Thread -1208112240 (LWP 2767) exited]

Program exited normally.
(gdb) q

Comment 4 Jan Kratochvil 2007-10-01 20:37:33 UTC
(In reply to comment #0)
> The kernel version is:
> Linux version 2.6.22.4-65.fc7 (kojibuilder.redhat.com) (gcc
version 4.1.2 20070502 (Red Hat 4.1.2-12)) #1 SMP Tue Aug 21 22:36:56 EDT 2007

BTW you run i686 kernel according to the timestamp, still it is unreproducible
for me.
I would be interested if there is some incompatibility.


Comment 5 Tim Michals 2007-10-02 02:01:08 UTC
Ok, this might be a user error, but... I did exactly what you did and yes it
worked.  I'm using the latest and greatest from boost cvs. So mine is in
/usr/local/lib... So using that library and changing the path ...
[tcmichals@localhost examples]$ g++ -o helloworld helloworld.cpp -Wall -ggdb2 -
pthread -L/usr/local/lib -lboost_thread-gcc41-mt-d
[tcmichals@localhost examples]$ gdb helloworld
GNU gdb Red Hat Linux (6.6-15.fc7rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) b main
Breakpoint 1 at 0x8048a78: file helloworld.cpp, line 17.
(gdb) start
Breakpoint 2 at 0x8048a78: file helloworld.cpp, line 17.
Starting program: /home/tcmichals/examples/helloworld
/home/tcmichals/examples/helloworld: error while loading shared libraries: libb
ost_thread-gcc41-mt-d-1_35.so.1.35.0: cannot open shared object file: No such f
le or directory

Program exited with code 0177.
(gdb) exit
Undefined command: "exit".  Try "help".
(gdb) quit
[tcmichals@localhost examples]$ export LD_LIBRARY_PATH=/usr/local/lib
[tcmichals@localhost examples]$ gdb helloworld
GNU gdb Red Hat Linux (6.6-15.fc7rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) b main
Breakpoint 1 at 0x8048a78: file helloworld.cpp, line 17.
(gdb) start
Breakpoint 2 at 0x8048a78: file helloworld.cpp, line 17.
Starting program: /home/tcmichals/examples/helloworld
[Thread debugging using libthread_db enabled]
[New Thread -1209014576 (LWP 2826)]
[Switching to Thread -1209014576 (LWP 2826)]

Breakpoint 1, main () at helloworld.cpp:17
17          boost::thread thrd(&helloworld);
(gdb)

It worked!!!
ok if I do the following:
The program is running.  Exit anyway? (y or n) y
[tcmichals@localhost examples]$ g++ -static -o helloworld helloworld.cpp -Wall
-ggdb2 -pthread -L/usr/local/lib -lboost_thread-gcc41-mt-d
[tcmichals@localhost examples]$
[tcmichals@localhost examples]$ ls /usr/local/lib/libboost_thread*
/usr/local/lib/libboost_thread-gcc41-mt-1_35.a
/usr/local/lib/libboost_thread-gcc41-mt-1_35.so
/usr/local/lib/libboost_thread-gcc41-mt-1_35.so.1.35.0
/usr/local/lib/libboost_thread-gcc41-mt.a
/usr/local/lib/libboost_thread-gcc41-mt-d-1_35.a
/usr/local/lib/libboost_thread-gcc41-mt-d-1_35.so
/usr/local/lib/libboost_thread-gcc41-mt-d-1_35.so.1.35.0
/usr/local/lib/libboost_thread-gcc41-mt-d.a
/usr/local/lib/libboost_thread-gcc41-mt-d.so
/usr/local/lib/libboost_thread-gcc41-mt.so
[tcmichals@localhost examples]$

[tcmichals@localhost examples]$ gdb helloworld
GNU gdb Red Hat Linux (6.6-15.fc7rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) b main
Breakpoint 1 at 0x80482ac: file helloworld.cpp, line 17.
(gdb) start
Breakpoint 2 at 0x80482ac: file helloworld.cpp, line 17.
Starting program: /home/tcmichals/examples/helloworld
[Thread debugging using libthread_db enabled]
Cannot find new threads: generic error
(gdb)
Then I try to exit gdb and it locks up... But I thought -static links the static
library?  
well, now atleast I know what the difference is and the issue, but don't know why.



Comment 6 Tim Michals 2007-10-02 03:22:42 UTC
http://sourceware.org/ml/gdb/2007-10/msg00009.html
You need a current CVS snapshot of both gdb and glibc to debug static
applications using NPTL.  It won't be fixed until GDB 6.7 and GLIBC
2.7.


So, have to wait.. but understand the issue now...

Comment 7 Jan Kratochvil 2007-10-02 07:23:17 UTC
Yes, static binaries with threads is a known problem, you should have written
the compilation commandline.
http://people.redhat.com/drepper/no_static_linking.html


Comment 8 Jan Kratochvil 2008-01-11 16:52:56 UTC
glibc is already fixed in Fedora 8; it is still broken in Fedora 7.
GDB got a fix now
  * Thu Jan 10 2008 Jan Kratochvil <jan.kratochvil> - 6.6-40
  - Fix+test (backport) threading of statically linked inferiors (BZ 314131).
    - It requires recent glibc to work in this case properly.
being now built as:
  http://koji.fedoraproject.org/koji/taskinfo?taskID=342641
and it should be pushed by Bodhi / Fedora Updates soon.

Fedora 7 would primarily need the glibc fix; I would suggest Fedora 8 upgrade as
a better choice.


Comment 9 Fedora Update System 2008-01-15 22:56:45 UTC
gdb-6.6-40.fc8 has been pushed to the Fedora 8 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.