This is the mail archive of the gdb-patches@sourceware.org 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]

Re: [RFA] Fix crash on Linux 2.4 when threaded program exits


> > 2009-04-01  Joel Brobecker  <brobecker@adacore.com>
> > 
> >         * linux-nat.c (linux_nat_filter_events): Do not delete the lwp if
> >         this is the last one.

> Yes, this is OK.

Thanks :)

> The comments about ntpl and thread exit notifications on nptl
> are confusing to a reader considering Linux 2.6.  They could do
> with a:
> 
>  s/In the nptl thread model/In the nptl thread model on Linux 2.4/.
> 
> wait_lwp does mention this 2.4 + backported nptl artifact explicitly.

That's a good suggestion. Attached is the patch I ended checking in.

Thanks for the quick review,
-- 
Joel
Index: linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-nat.c,v
retrieving revision 1.126
diff -u -p -r1.126 linux-nat.c
--- linux-nat.c	25 Mar 2009 10:02:13 -0000	1.126
+++ linux-nat.c	1 Apr 2009 18:54:37 -0000
@@ -2623,16 +2623,16 @@ linux_nat_filter_event (int lwpid, int s
   /* Check if the thread has exited.  */
   if ((WIFEXITED (status) || WIFSIGNALED (status)) && num_lwps > 1)
     {
-      /* If this is the main thread, we must stop all threads and
-	 verify if they are still alive.  This is because in the nptl
-	 thread model, there is no signal issued for exiting LWPs
+      /* If this is the main thread, we must stop all threads and verify
+	 if they are still alive.  This is because in the nptl thread model
+	 on Linux 2.4, there is no signal issued for exiting LWPs
 	 other than the main thread.  We only get the main thread exit
 	 signal once all child threads have already exited.  If we
 	 stop all the threads and use the stop_wait_callback to check
 	 if they have exited we can determine whether this signal
 	 should be ignored or whether it means the end of the debugged
 	 application, regardless of which threading model is being
-	 used.  */
+	 used.	*/
       if (GET_PID (lp->ptid) == GET_LWP (lp->ptid))
 	{
 	  lp->stopped = 1;
@@ -2644,13 +2644,14 @@ linux_nat_filter_event (int lwpid, int s
 			    "LLW: %s exited.\n",
 			    target_pid_to_str (lp->ptid));
 
-      exit_lwp (lp);
-
-      /* If there is at least one more LWP, then the exit signal was
-	 not the end of the debugged application and should be
-	 ignored.  */
-      if (num_lwps > 0)
-	return NULL;
+      if (num_lwps > 1)
+       {
+	 /* If there is at least one more LWP, then the exit signal
+	    was not the end of the debugged application and should be
+	    ignored.  */
+	 exit_lwp (lp);
+	 return NULL;
+       }
     }
 
   /* Check if the current LWP has previously exited.  In the nptl

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