public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug threads/10970] New: GDB hangs when main thread does pthread_exit
@ 2009-11-17  5:35 ppluzhnikov at google dot com
  2009-11-17  5:44 ` [Bug threads/10970] " ppluzhnikov at google dot com
  0 siblings, 1 reply; 4+ messages in thread
From: ppluzhnikov at google dot com @ 2009-11-17  5:35 UTC (permalink / raw)
  To: gdb-prs

Test case:

--- cut ---
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>

void *
fn (void *p)
{
  int i;
  printf ("thread %p\n", (void *) pthread_self ());
  for (i = 0; i < 60; ++i)
    {
      printf ("i = %d\n", i);
      sleep (1);
    }
  printf ("thread %p done\n", (void *) pthread_self ());
  return NULL;
}

int main ()
{
  pthread_t tid;
  pthread_create (&tid, NULL, fn, NULL);
  pthread_exit (0);
}
--- cut ---

gcc -g -pthread hang.c -o hang
gdb-cvs -nx ./hang
NU gdb (GDB) 7.0.50.20091116-cvs
...
This GDB was configured as "x86_64-unknown-linux-gnu".
...
Reading symbols from /usr/local/google/tmp/hang...done.
(gdb) run
Starting program: /usr/local/google/tmp/hang 
[Thread debugging using libthread_db enabled]
[New Thread 0x40800950 (LWP 1540)]
thread 0x40800950
i = 0
i = 1
i = 2
i = 3
i = 4
       <<< hit Control-C here; the counter stops, but there is no GDB prompt.
   The only way to "recover" is "killall -9 gdb-cvs" in another window, at which
point inferior resumes (in the background):

i = 5
Killed
$ i = 6
i = 7
i = 8
...

-- 
           Summary: GDB hangs when main thread does pthread_exit
           Product: gdb
           Version: 6.8
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: threads
        AssignedTo: unassigned at sourceware dot org
        ReportedBy: ppluzhnikov at google dot com
                CC: gdb-prs at sourceware dot org
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://sourceware.org/bugzilla/show_bug.cgi?id=10970

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug threads/10970] GDB hangs when main thread does pthread_exit
  2009-11-17  5:35 [Bug threads/10970] New: GDB hangs when main thread does pthread_exit ppluzhnikov at google dot com
@ 2009-11-17  5:44 ` ppluzhnikov at google dot com
  0 siblings, 0 replies; 4+ messages in thread
From: ppluzhnikov at google dot com @ 2009-11-17  5:44 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From ppluzhnikov at google dot com  2009-11-17 05:44 -------
Same result with breakpoints as well:

gdb64-cvs -q -nx ./hang
Reading symbols from /usr/local/google/tmp/multiple-so/hang...done.
(gdb) list
13	      sleep (1);
14	    }
15	  printf ("thread %p done\n", (void *) pthread_self ());
16	  return NULL;
17	}
18	
19	int main ()
20	{
21	  pthread_t tid;
22	  pthread_create (&tid, NULL, fn, NULL);
(gdb) b 13
Breakpoint 1 at 0x400686: file hang.c, line 13.
(gdb) r
Starting program: /usr/local/google/tmp/hang 
[Thread debugging using libthread_db enabled]
[New Thread 0x40800950 (LWP 2631)]
thread 0x40800950
i = 0
[Switching to Thread 0x40800950 (LWP 2631)]

Breakpoint 1, fn (p=0x0) at hang.c:13
13	      sleep (1);
(gdb) c
Continuing.
i = 1
      <<< no further progress from here; can't gain GDB prompt with Control-C.

I verified that if I replace pthread_exit() with sleep(300), GDB starts working
fine.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1


http://sourceware.org/bugzilla/show_bug.cgi?id=10970

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug threads/10970] GDB hangs when main thread does pthread_exit
       [not found] <bug-10970-4717@http.sourceware.org/bugzilla/>
  2011-05-27 16:56 ` cvs-commit at gcc dot gnu.org
@ 2011-05-27 16:59 ` jan.kratochvil at redhat dot com
  1 sibling, 0 replies; 4+ messages in thread
From: jan.kratochvil at redhat dot com @ 2011-05-27 16:59 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=10970

Jan Kratochvil <jan.kratochvil at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |jan.kratochvil at redhat
                   |                            |dot com
         Resolution|                            |FIXED

--- Comment #3 from Jan Kratochvil <jan.kratochvil at redhat dot com> 2011-05-27 16:58:20 UTC ---
Fixed.

i = 4
[Thread 0x7ffff7fe6720 (LWP 5622) exited]

Program received signal SIGINT, Interrupt.
[Switching to Thread 0x7ffff7822700 (LWP 5625)]
0x00007ffff78d0ced in nanosleep () at ../sysdeps/unix/syscall-template.S:82
82    T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
(gdb) _

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug threads/10970] GDB hangs when main thread does pthread_exit
       [not found] <bug-10970-4717@http.sourceware.org/bugzilla/>
@ 2011-05-27 16:56 ` cvs-commit at gcc dot gnu.org
  2011-05-27 16:59 ` jan.kratochvil at redhat dot com
  1 sibling, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2011-05-27 16:56 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=10970

--- Comment #2 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> 2011-05-27 16:55:43 UTC ---
CVSROOT:    /cvs/src
Module name:    src
Changes by:    jkratoch@sourceware.org    2011-05-27 16:55:39

Modified files:
    gdb            : ChangeLog linux-nat.c 
    gdb/testsuite  : ChangeLog 
Added files:
    gdb/testsuite/gdb.threads: leader-exit.c leader-exit.exp 

Log message:
    gdb/
    Fix PR 10970, PR 12702.
    * linux-nat.c (linux_lwp_is_zombie): New function.
    (wait_lwp): Initialize status.  New variable prev_mask.  Block signals.
    Check for linux_lwp_is_zombie.  Use WNOHANG and sigsuspend.

    gdb/testsuite/
    * gdb.threads/leader-exit.c: New file.
    * gdb.threads/leader-exit.exp: New file.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.13060&r2=1.13061
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/linux-nat.c.diff?cvsroot=src&r1=1.205&r2=1.206
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2728&r2=1.2729
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.threads/leader-exit.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.threads/leader-exit.exp.diff?cvsroot=src&r1=NONE&r2=1.1

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

end of thread, other threads:[~2011-05-27 16:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-17  5:35 [Bug threads/10970] New: GDB hangs when main thread does pthread_exit ppluzhnikov at google dot com
2009-11-17  5:44 ` [Bug threads/10970] " ppluzhnikov at google dot com
     [not found] <bug-10970-4717@http.sourceware.org/bugzilla/>
2011-05-27 16:56 ` cvs-commit at gcc dot gnu.org
2011-05-27 16:59 ` jan.kratochvil at redhat dot com

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).