GNU gdb 6.0
Copyright 2003 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 "i686-pc-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) run
Starting program: /home/maik/programming/c/simplescan/a.out
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 7863)]
[New Thread 32769 (LWP 7866)]
[New Thread 16386 (LWP 7867)]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 7863)]
0x40037394 in pthread_create@@GLIBC_2.1 () from /lib/libpthread.so.0
$ gcc -static -pthread -Wall -ggdb max_threads.c
$ ./a.out
Segmentation fault
$ gdb a.out
GNU gdb 6.0
Copyright 2003 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 "i686-pc-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) run
Starting program: /home/maik/programming/c/simplescan/a.out
Program received signal SIG32, Real-time event 32.
0x0804ab0f in __pthread_sigsuspend ()
(gdb)
Last edited by Lateralus on 06. May 2005 18:39, edited 2 times in total.
Ich schätze mal, daß das erste Argument nicht NULL sein darf, da darin ein Thread-Handle zurückgegeben wird. Außerdem liefert die Funktion im Erfolgsfall 0, du mußt also ein ! vor die Funktion setzen.
Gruß,
hjb
Pro-Linux - warum durch Fenster steigen, wenn es eine Tür gibt?
$ gdb a.out
GNU gdb 6.0
Copyright 2003 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 "i686-pc-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) run
Starting program: a.out
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 17285)]
[New Thread 32769 (LWP 17288)]
[New Thread 16386 (LWP 17289)]
[New Thread 32771 (LWP 17290)]
[New Thread 49156 (LWP 17291)]
[New Thread 65541 (LWP 17292)]
[New Thread 81926 (LWP 17293)]
[New Thread 98311 (LWP 17294)]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 65541 (LWP 17292)]
0x08048537 in func_b (arg=0xbf7ffac4) at pthread_segfault.c:18
18 if( pthread_equal(myself, my_xyz->b_threads[i]) )
Ich habe dein Programm kurz durch den Debugger gequetscht, aber ich sehe zunächst die Ursache auch nicht.
Wenn ich das recht sehe, erzeugst du zuerst 3 Threads, die func_a ausführen. Jeder von diesen erzeugt 3 Threads, die func_b ausführen. Diese teilen sich aber die 3 Thread-Handles in b_threads. Ob das den Crash verursacht, weiß ich nicht, aber es wäre möglich.
Gruß,
hjb
Pro-Linux - warum durch Fenster steigen, wenn es eine Tür gibt?