From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21946 invoked by alias); 30 Mar 2018 06:23:20 -0000 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 Received: (qmail 21259 invoked by uid 89); 30 Mar 2018 06:23:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=increases, hitting X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 30 Mar 2018 06:23:18 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id w2U6NBrs025244 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 30 Mar 2018 02:23:16 -0400 Received: by simark.ca (Postfix, from userid 112) id 9850E1E77A; Fri, 30 Mar 2018 02:23:11 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 0BD171E030; Fri, 30 Mar 2018 02:23:11 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 30 Mar 2018 06:23:00 -0000 From: Simon Marchi To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Fix gdb.base/fork-running-state.exp race In-Reply-To: <20180328150630.18319-1-palves@redhat.com> References: <20180328150630.18319-1-palves@redhat.com> Message-ID: <12eacdba1ae3cb9cc58c050601ddf958@polymtl.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.4 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 30 Mar 2018 06:23:11 +0000 X-IsSubscribed: yes X-SW-Source: 2018-03/txt/msg00607.txt.bz2 On 2018-03-28 11:06, Pedro Alves wrote: > On my multi-target branch I was occasionaly seeing a FAIL like this: > > (gdb) PASS: gdb.base/fork-running-state.exp: detach-on-fork=off: > follow-fork=parent: non-stop: kill parent > [Inferior 2 (process 32672) exited normally] > kill inferior 2 > warning: Inferior ID 2 is not running. > (gdb) FAIL: gdb.base/fork-running-state.exp: detach-on-fork=off: > follow-fork=parent: non-stop: kill child (the program exited) > ... other similar fails ... > > Turns out to be a testcase bug/race. A tweak like this increases the > changes of hitting the race substancially: > > --- a/gdb/testsuite/gdb.base/fork-running-state.c > +++ b/gdb/testsuite/gdb.base/fork-running-state.c > @@ -29,7 +29,7 @@ fork_child (void) > { > while (1) > { > - sleep (1); > + usleep (100); > > > The testcase has two processes, parent and child fork. The problem is > that the child exits itself if it notices the parent is gone, but the > testcase .exp does not expect that. > > I first wrote a patch that handled the different combinations of > non-stop/detach-on-fork/follow-fork/schedule-multiple, making the .exp > file know when to expect the child to exit itself vs when to kill it > explicitly, but the result was that the code to kill the parent and > child was getting about as large as the test code that is the actual > point of the testcase, above the kills. > > So I scratched that approach and came up with a simpler patch -- > simply make the child not exit itself when the parent exits. > > The .exp file is going to kill both parent and child explicitly, and, > main() already calls alarm() as a safeguard. I don't think we lose > anything. Does the parent exit as part of the test, or only when we kill it at the end when we clean up? If I understand correctly, we kill the parent, and by the time we want to kill the child, it has already noticed the parent is gone and has itself exited, is that right? In that case I think it makes sense to have only one way of cleaning up, either we kill the process or we let it exit, not both. So the patch LGTM. Simon