Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2009-10

gdb: "Cannot find new threads: generic error"

7 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin Schreiber

Hi,

linux-i386 Suse 11.1, binutils 2.19.51-15.1, the program:
"
program gdbthread;
{$mode objfpc}{$h+}
uses
 cthreads,sysutils;
begin
end.
"

The compile - debug session:
"

ppc386 -gl

gdbthread.pas
Free Pascal Compiler version 2.2.4 [2009/03/28] for i386 Copyright (c) 1993-2008 by Florian Klaempfl
Target OS: Linux for i386
Compiling gdbthread.pas
Linking gdbthread
/usr/bin/ld: warning: link.res contains output sections; did you forget -T? 6 lines compiled, 0.3 sec

gdb ./gdbthread

GNU gdb (GDB; openSUSE 11.1) 6.8.50.20081120-cvs
Copyright (C) 2008 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 "i586-suse-linux".
For bug reporting instructions, please see:
<http://bugs.opensuse.org/>...
(gdb) break main
Breakpoint 1 at 0x80483f8: file gdbthread.pas, line 6. (gdb) run
Starting program: /home/mse/proj/msegui/testcase/FPC/2_2_4/gdbthread/gdbthread [Thread debugging using libthread_db enabled]
Error while reading shared library symbols:
Cannot find new threads: generic error
Cannot find new threads: generic error
(gdb)
"

What is wrong? Bigger gui-programs are working.

Martin

Reply by email

Martin Schreiber
to Jonas Maebe
Jonas Maebe wrote 11 lines
On 09 Oct 2009, at 13:44, Martin Schreiber wrote: > What is wrong? Bigger gui-programs are working. Seems to be unrelated to FPC: http://forums.opensuse.org/programming-scripting/412939-gdb-unable-debug-ap plication.html Here is a hint as to what might be the cause: http://www.nabble.com/Cannot-find-new-threads:-generic-error-td19019624.htm l

That means the linker removes libpthread.so and gdb can't work without? "
program gdbthread;
{$mode objfpc}{$h+}
uses
 cthreads,sysutils,msethread;
begin
end.
"
or
"
program gdbthread;
{$mode objfpc}{$h+}
uses
sysutils;
begin
end.
"
work. So I must remove cthreads from the console program template and hope the users don't forget to add it if they use threads. Possibly a new effect with binutils with the dynlib fix.

Thanks, Martin

Reply by email

Jonas Maebe
to Martin Schreiber
Martin Schreiber wrote 14 lines
On Friday 09 October 2009 13:49:14 Jonas Maebe wrote: > On 09 Oct 2009, at 13:44, Martin Schreiber wrote: >> What is wrong? Bigger gui-programs are working. > > Seems to be unrelated to FPC: > http://forums.opensuse.org/programming-scripting/412939-gdb-unable-debug-ap > plication.html > > Here is a hint as to what might be the cause: > http://www.nabble.com/Cannot-find-new-threads:-generic-error-td19019624.htm > l > That means the linker removes libpthread.so and gdb can't work without?

There is nothing to remove by the linker in case of your FPC program, because the cthreads unit does not explicitly link to libpthread. It tries to dynamically load the library at run time.

Show quoted text 5 lines
So I must remove cthreads from the console program template and hope the users don't forget to add it if they use threads. Possibly a new effect with binutils with the dynlib fix.

Where did you see that this was caused by a bug in binutils?

Jonas

Reply by email

Martin Schreiber
to Jonas Maebe
Jonas Maebe wrote 9 lines
On 09 Oct 2009, at 14:11, Martin Schreiber wrote: > > That means the linker removes libpthread.so and gdb can't work > without? There is nothing to remove by the linker in case of your FPC program, because the cthreads unit does not explicitly link to libpthread. It tries to dynamically load the library at run time.

Then I don't understand the problem.

Show quoted text 8 lines
> So I must remove cthreads from the console program template and hope > the > users don't forget to add it if they use threads. Possibly a new > effect with > binutils with the dynlib fix. Where did you see that this was caused by a bug in binutils?

It was not caused by a bug in binutils but the new binutils with the bugfix showed the problem the first time. With original Suse 11.1 binutils gdb could handle the console program template IIRC.

Martin

Reply by email

Jonas Maebe
to Martin Schreiber
Martin Schreiber wrote 12 lines
On Friday 09 October 2009 14:18:37 Jonas Maebe wrote: > On 09 Oct 2009, at 14:11, Martin Schreiber wrote: >> >> That means the linker removes libpthread.so and gdb can't work >> without? > > There is nothing to remove by the linker in case of your FPC program, > because the cthreads unit does not explicitly link to libpthread. It > tries to dynamically load the library at run time. > Then I don't understand the problem.

The problem appears to be that something goes wrong with dynamically loading libpthread in case the program has not been linked to it at compile time. That would explain why it works when you use msethread, because that one explicitly links to libpthread at compile time (via the imports in mselibc, I guess).

Why dynamically loading libpthread causes problems is another question. Maybe somehow the cthreads unit loads a different ("wrong") copy of libpthread than the one the static linker uses when linking the program. Or, alternatively, maybe the static linker selects a different version of libc to link against if libpthread is also used (libc and libpthread are quite interwoven on GNU systems, even though they are separate libraries).

It was not caused by a bug in binutils but the new binutils with the bugfix

With which bugfix? And are you certain that only binutils was updated?

Jonas

Reply by email