From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26011 invoked by alias); 1 Apr 2009 18:58:29 -0000 Received: (qmail 26002 invoked by uid 22791); 1 Apr 2009 18:58:28 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 01 Apr 2009 18:58:17 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id CBD982C0BE2; Wed, 1 Apr 2009 14:58:15 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id UwP7-BOpdqOL; Wed, 1 Apr 2009 14:58:15 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 90B732C0BDC; Wed, 1 Apr 2009 14:58:15 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id E463EF5A6F; Wed, 1 Apr 2009 11:58:12 -0700 (PDT) Date: Wed, 01 Apr 2009 18:58:00 -0000 From: Joel Brobecker To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [RFA] Fix crash on Linux 2.4 when threaded program exits Message-ID: <20090401185812.GF8766@adacore.com> References: <20090401182220.GG16605@adacore.com> <200904011942.40306.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="gBBFr7Ir9EOA20Yy" Content-Disposition: inline In-Reply-To: <200904011942.40306.pedro@codesourcery.com> User-Agent: Mutt/1.5.18 (2008-05-17) Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-04/txt/msg00008.txt.bz2 --gBBFr7Ir9EOA20Yy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 602 > > 2009-04-01 Joel Brobecker > > > > * 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 --gBBFr7Ir9EOA20Yy Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="thread-24.diff" Content-length: 1975 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 --gBBFr7Ir9EOA20Yy--