GDB can't debug apps that use threads (libpthread.so) on Mandrake 9.0.
There are two reasons for this, both caused by Mandrake's broken
installation of glibc. I finally got these problems fixed on my
system, with lots of help from a co-worker and day of debugging GDB
with itself. 

1. The first problem was that the shared library libpthread.so had its
symbols stripped by Mandrake.  The symptom is that GDB complains about
a weird signals (SIG32, to be exact) when debugging a program that
uses pthreads.

The fix was to install the glibc source RPM, rebuild it ('rpm -bc
glibc.spec'), and copy the non-stripped i686-specific libpthread
shared library to /lib/i686.  If you are in the build directory
/usr/src/RPM/BUILD/glibc-2.2.5, then copy the file as follows:

  cp build-i686-linux2.4/linuxthreads/libpthread.so /lib/i686/libpthread-0.9.so

After this, run 'ldconfig -v' just to be sure the new library gets
used, but it's probably not necessary.

NOTE: yes, there really are two libpthread shared libraries, one in
/lib (generic), and one in /lib/i686 (Intel 686-specific).  There
are important differences between the two, such as the sizes of
certain thread data structures and the presence of certain functions.
The data structure size mismatch turned out to the source of problem 2
below.  I suspect the generic library in /lib should not even have been
installed by Mandrake, since it's not used by apps that are linked
with -lpthread.

The more permanent fix, which Mandrake should be using, would be to
edit the spec file (glibc.spec), and adding libpthread to the list of
libraries to NOT strip:

  EXCLUDE_FROM_STRIP="ld-%{glibcversion}.so libpthread-0.9.so"

The exact spelling of the library filename must be given as shown.
Then the binary RPM can be built (I haven't tried this myself yet).

2. Once that problem was fixed, GDB would now crash with a segfault
debugging pthread apps.  This turned out to be due to the data
structure size mismatch mentioned above.  GDB was using the generic
libthread_db.so (the thread debugging librrary) in /lib, which had a
different idea of the size of the _pthread_descr_struct structure than
the app being debugged, which used the processor-specific pthread
library in /lib/i686.

I chose to fix this by copying the i686-specific libthread_db.so to
/lib/i686.  If you are in the build directory
/usr/src/RPM/BUILD/glibc-2.2.5, then copy the file as follows:

  cp build-i686-linux2.4/linuxthreads_db/libthread_db.so \
    /lib/i686/libthread_db-1.0.so

Then move to the directory /lib/i686 and create the following symbolic
link:

  ln -s libthread_db-1.0.so libthread_db.so.1

Finally, run 'ldconfig -v' to make sure this library gets put in front
of the bad one in /lib.

I'm not sure what permanent fix Mandrake should be using.  Either the
spec file or one of the Makefiles should be edited to copy the thread
debugging library to the correct directory; I haven't looked into this
yet.

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Reply via email to