bug-gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Limited to 255 threads in gdb 5.1 ?


From: Andrew Burgess
Subject: Limited to 255 threads in gdb 5.1 ?
Date: 7 Jan 2002 21:23:40 -0800

It seems that even if threads are exited and joined that once 255
have been created then no more can be created in gdb 5.1

Here is a test program. From the shell it runs to the tens of 
thousands of threads, in gdb I get:

athlon:ha > gdb -nx thtest
GNU gdb Red Hat Linux (5.1-2)
Copyright 2001 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"...
(gdb) run
Starting program: /v/src/ha/thtest 
[New Thread 1024 (LWP 10497)]
[New Thread 2049 (LWP 10554)]
[New Thread 1026 (LWP 10555)]
1 [New Thread 2051 (LWP 10556)]
2 [New Thread 3076 (LWP 10557)]
3 [New Thread 4101 (LWP 10558)]
4 [New Thread 5126 (LWP 10559)]
...
252 [New Thread 259326 (LWP 11578)]
253 [New Thread 260351 (LWP 11579)]
254 [New Thread 261376 (LWP 11580)]
255 
<stops here, I press ^C>
Program received signal SIGINT, Interrupt.
[Switching to Thread 1024 (LWP 10497)]
0x40071b85 in __sigsuspend (set=0xbfffed10) at
../sysdeps/unix/sysv/linux/sigsuspend.c:45
45      ../sysdeps/unix/sysv/linux/sigsuspend.c: No such file or
directory.
        in ../sysdeps/unix/sysv/linux/sigsuspend.c
(gdb) info threads
  2 Thread 2049 (LWP 10554)  0x4012d5c3 in __mmap () from
/lib/i686/libc.so.6
* 1 Thread 1024 (LWP 10497)  0x40071b85 in __sigsuspend
(set=0xbfffed10) at ../sysdeps/unix/sysv/linux/sigsuspend.c:45
(gdb) where
#0  0x40071b85 in __sigsuspend (set=0xbfffed10) at
../sysdeps/unix/sysv/linux/sigsuspend.c:45
#1  0x400371c9 in __pthread_wait_for_restart_signal (self=0x4003ff40)
at pthread.c:969
#2  0x4003729c in __pthread_create_2_1 (thread=0xbfffee94, attr=0x0,
start_routine=0x80485f0 <start>, arg=0x0)
    at restart.h:34
#3  0x08048628 in make ()
#4  0x080486a5 in main ()
#5  0x4005f627 in __libc_start_main (main=0x8048698 <main>, argc=1,
ubp_av=0xbfffef14, init=0x804841c <_init>,
    fini=0x80486f0 <_fini>, rtld_fini=0x4000dcc4 <_dl_fini>,
stack_end=0xbfffef0c) at ../sysdeps/generic/libc-start.c:129
(gdb) 

===============================================================
thtest.c:

/* recursively create threads until creation fails, then unwind the
recursion
and join all threads. Repeat.
*/

#include <stdio.h>
#include <pthread.h>

int count;

void *start(void *arg) {
        sleep(1);
        pthread_exit(NULL);
}

void make(void) {
        pthread_t t;
        int status = pthread_create(&t, NULL, start, NULL);
        switch(status) {
          case 0:
            break;
          default:
            return;
        }
        if(++count % 100) {
          printf("\r%d ", count);
          fflush(stdout);
        }
        make();
        pthread_join(t, NULL);
}

int main(int argc, char *argv[]) {
        while(1)
          make();
        return 0;
}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]