This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

SIG32/SIGTRAP issues


Hi,

I seem to be running into a bit of an odd problem. When I have a
threaded application thats shared, everything works fine .. in the event
that the application is statically linked however, gdb gets a SIG32 at
pthread_create() time and doesn't track the threads properly.

Using the following code:

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

#define MAX_NUM_THREADS 1024

void *thread_func( void * not_used )
{
	printf("Starting real thread %d\n", *(int *)not_used);
	sleep(2);
	printf("Ending thread\n");
}

main()
{
	int i,j,k;
	int num_of_threads;
	pthread_t thread[MAX_NUM_THREADS];

	printf("Enter the number of threads reqd(<=1024): ");
	scanf("%d", &num_of_threads);
	for ( i=0; i<num_of_threads; i++ ) {
		printf("Starting thread %d\n", i);
		if ( pthread_create( &(thread[i]), NULL, thread_func, &i ) != 0 )
			perror("");
		printf("created thread %d\n", i);
	}
	for ( i=0; i<num_of_threads; i++ ) {
		pthread_join( thread[i], NULL );
	}
}

Running shared, everything looks okay:

[root@lemur gdb-build]# gdb/gdb
GNU gdb 5.2.90_2002-12-03-cvs
Copyright 2002 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".
(gdb) file /mnt/test-shared
Reading symbols from /mnt/test-shared...done.
(gdb) break thread_func
Breakpoint 1 at 0x80485c6
(gdb) run
Starting program: /mnt/test-shared
[New Thread 1024 (LWP 24053)]
Enter the number of threads reqd(<=1024): 2
Starting thread 0
[New Thread 2049 (LWP 24054)]
[New Thread 1026 (LWP 24055)]
created thread 0
Starting thread 1
[Switching to Thread 1026 (LWP 24055)]

Breakpoint 1, 0x080485c6 in thread_func ()
(gdb) c
Continuing.
Starting real thread 1
[New Thread 2051 (LWP 24056)]
Ending thread
created thread 1
[Switching to Thread 2051 (LWP 24056)]

Breakpoint 1, 0x080485c6 in thread_func ()
(gdb) c
Continuing.
Starting real thread 1
Ending thread

Program exited with code 02.
(gdb)

But when I run it statically, I get the following:

[root@lemur gdb-build]# gdb/gdb
GNU gdb 5.2.90_2002-12-03-cvs
Copyright 2002 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".
(gdb) file /mnt/test-static
Reading symbols from /mnt/test-static...done.
(gdb) break thread_func
Breakpoint 1 at 0x80481e6
(gdb) run
Starting program: /mnt/test-static
Enter the number of threads reqd(<=1024): 2
Starting thread 0

Program received signal SIG32, Real-time event 32.
0x0804e6c6 in __sigsuspend (set=0xbfffe970) 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) c
Continuing.

Program received signal SIGTRAP, Trace/breakpoint trap.
pthread_handle_sigrestart (sig=-1073747600) at pthread.c:825
825     pthread.c: No such file or directory.
        in pthread.c
(gdb) c
Continuing.
created thread 0
Starting thread 1

and at that point it just sits there and hangs indefinitely.

If I omit the break, I don't get the SIGTRAP (obviously) and it runs
through fine, though I'm not able to track any kind of thread
information while its running.

Looking through the PRs and gdb/PROBLEMS, I don't see this mentioned
anywhere. Is this a known problem?

This same behavior is also observed under 5.2/5.2.1 on both x86/ppc.

Regards,

-- 
Paul Mundt <paul.mundt@timesys.com>
TimeSys Corporation

Attachment: signature.asc
Description: This is a digitally signed message part


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]