Ok, somewhere today I noticed that a bug with pthread exiting was known, so I
checked that, and that is the problem here.
So, setting up the threads such that they never exit, GDB gives the following
error: "thread_db: map_id2thr failed: invalid thread handle". What is happening
there is that gdb assumes thread id's are int's, but on Linux they are
unsigned long int (2.2.16 kernel) so GDB can't handle very many threads going
on simultaneously (I fail at around 32 threads).
On 13-Aug-00 Randy Austin wrote:
>
> gdb 5.0, Slackware 7.1 (glibc 2.1.3)
>
> The following program will run correctly without gdb, but will not run when
> run
> within GDB:
>
> /* compile with cc -o pthread_test pthread_test.c -lpthread */
>
>#include <pthread.h>
>
> void *pthread_test(void *);
>
> main()
> {
> int i;
> pthread_t tid;
>
> for(i=0;i<100;i++)
> {
> pthread_create(&tid,NULL,pthread_test,NULL);
> }
> }
>
> void *
> pthread_test(void *arg)
> {
> sleep(100);
> }
>
> Here is the output of running the above application
>
> randy@DontKnow:/tmp> ./pthread_test
> randy@DontKnow:/tmp> gdb ./pthread_test
> GNU gdb 5.0
> Copyright 2000 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-slackware-linux"...
> (gdb) run
> Starting program: /tmp/./pthread_test
> warning: Unable to find dynamic linker breakpoint function.
> GDB will be unable to debug shared library initializers
> and track explicitly loaded dynamic code.
> [New Thread 1024 (runnable)]
> [New Thread 2049 (runnable)]
> [New Thread 1026 (runnable)]
> [New Thread 2051 (runnable)]
>
> Program received signal SIGTRAP, Trace/breakpoint trap.
> [Switching to Thread 1026 (runnable)]
> 0x0 in ?? ()
> (gdb) info threads
> 4 Thread 2051 (runnable) 0x400d7efe in clone () from /lib/libc.so.6
> * 3 Thread 1026 (runnable) 0x0 in ?? ()
> 2 Thread 2049 (runnable) 0x40023d8d in __linuxthreads_create_event ()
> at events.c:24
> 1 Thread 1024 (runnable) 0x4004b56a in sigsuspend () from /lib/libc.so.6
>
> -------
>
> I will appreciate hearing about a patch, soon.
>
> --Randy Austin ([EMAIL PROTECTED])
>
> Contrary to popular belief, UNIX is user friendly.
> It just happens to be selective about who it makes friends with.
>
Contrary to popular belief, UNIX is user friendly.
It just happens to be selective about who it makes friends with.