public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* fork and pthreads
@ 2005-09-30 10:23 Sébastien Roret
  2005-09-30 13:08 ` Daniel Jacobowitz
  2005-09-30 14:49 ` Sébastien Roret
  0 siblings, 2 replies; 3+ messages in thread
From: Sébastien Roret @ 2005-09-30 10:23 UTC (permalink / raw)
  To: gdb

Hi, 
 
I'm having some problems using fork() with threads. 
I'm using a debian linux on Intel, gdb 6.3, glibc 2.3.3 and 2.3.5 
If I call forks before using threads it's ok, but not the other way. 
The problem occurs only with gdb. 
See below the testcase and output I got. 
My question : is it a bug, or did I missed something ? 
 
Thanks for any ideas. 
 
 
 
#include <sys/types.h> 
#include <unistd.h> 
#include <pthread.h> 
 
void* start_routine(void *arg) 
{ 
        printf("start_routine\n"); 
} 
 
int main() 
{ 
  pid_t pid; 
  pthread_t thread; 
  int status; 
 
  printf("pid=%d\n", getpid()); 
 
  pthread_create(&thread, NULL, &start_routine, NULL); 
  pthread_join(thread, NULL); 
  perror("join"); 
 
  pid = fork(); 
 
  printf("fork pid = %d\n", pid); 
  if( pid == -1 ) 
  { 
         perror( "fork" ); 
         abort(); 
  } 
  else if( pid == 0 ) 
  { 
        printf("pid = %d\n", pid); 
        sleep(1); 
        return 0; 
  } 
  else 
  { 
       printf("waiting child pid = %d\n", pid); 
       printf("wait=%d\n", wait( &status )); 
       printf("status=%d\n", status ); 
       return 0; 
  } 
} 
 
Then : 
$ gcc pthread_fork.c -o pthread_fork -lpthread 
$ gdb ./pthread_fork 
GNU gdb 6.3-debian 
Copyright 2004 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-linux"...Using host libthread_db library 
"/lib/tls/libthread_db.so.1". 
 
(gdb) r 
Starting program: /tmp/pthread_fork 
[Thread debugging using libthread_db enabled] 
[New Thread 1075145376 (LWP 10278)] 
pid=10278 
[New Thread 1083534256 (LWP 10283)] 
start_routine 
[Thread 1083534256 (LWP 10283) exited] 
join: Success 
ptrace: No such process. 
thread_db_get_info: cannot get thread info: generic error 
(gdb) fork pid = 0 
pid = 0 
fork pid = 10284 
waiting child pid = 10284 
 
 
 
 
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: fork and pthreads
  2005-09-30 10:23 fork and pthreads Sébastien Roret
@ 2005-09-30 13:08 ` Daniel Jacobowitz
  2005-09-30 14:49 ` Sébastien Roret
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Jacobowitz @ 2005-09-30 13:08 UTC (permalink / raw)
  To: Sébastien Roret; +Cc: gdb

On Fri, Sep 30, 2005 at 09:58:05AM +0000, Sébastien Roret wrote:
> Hi, 
>  
> I'm having some problems using fork() with threads. 
> I'm using a debian linux on Intel, gdb 6.3, glibc 2.3.3 and 2.3.5 
> If I call forks before using threads it's ok, but not the other way. 
> The problem occurs only with gdb. 
> See below the testcase and output I got. 
> My question : is it a bug, or did I missed something ? 

Please try a CVS snapshot (6.3.50.*) and let us know if that works
better.


-- 
Daniel Jacobowitz
CodeSourcery, LLC

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: fork and pthreads
  2005-09-30 10:23 fork and pthreads Sébastien Roret
  2005-09-30 13:08 ` Daniel Jacobowitz
@ 2005-09-30 14:49 ` Sébastien Roret
  1 sibling, 0 replies; 3+ messages in thread
From: Sébastien Roret @ 2005-09-30 14:49 UTC (permalink / raw)
  To: gdb

I tried GNU gdb 6.3.50.20050930 with no success. 
I still have : 
"thread_db_get_info: cannot get thread info: generic error" 
I also tried g++ (GCC) 4.0.1 (Debian 4.0.1-2) : it seems that gdb no longer 
blocks on this error and continues the execution. 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-09-30 14:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-30 10:23 fork and pthreads Sébastien Roret
2005-09-30 13:08 ` Daniel Jacobowitz
2005-09-30 14:49 ` Sébastien Roret

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).