From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18140 invoked by alias); 13 Aug 2018 09:51:50 -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 18118 invoked by uid 89); 13 Aug 2018 09:51:49 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=H*RU:!127.0.0.1!, Hx-spam-relays-external:!127.0.0.1!, sleep, accesses X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 13 Aug 2018 09:51:47 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E10B140216FC; Mon, 13 Aug 2018 09:51:45 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 209EE1C701; Mon, 13 Aug 2018 09:51:44 +0000 (UTC) Subject: Re: [PATCH] gdb: Fix instability in thread groups test To: Simon Marchi , Andrew Burgess References: <20180810095750.13017-1-andrew.burgess@embecosm.com> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: <7da382e5-bd5e-25c2-b3f8-f38e692f35a1@redhat.com> Date: Mon, 13 Aug 2018 09:51:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-SW-Source: 2018-08/txt/msg00326.txt.bz2 On 08/10/2018 10:26 PM, Simon Marchi wrote: > On 2018-08-10 05:57, Andrew Burgess wrote: >> In the test script gdb.mi/list-thread-groups-available.exp we ask GDB >> to list all thread groups, and match the output against a >> regexp. Occasionally, I would see this test fail. >> >> The expected output is a list of entries, each entry looking roughly >> like this: >> >>   {id="",type="process",description="", >>    user="",cores=["","",...]} >> >> All the fields after 'id' and 'type' are optional, and the 'cores' >> list can contain 1 or more "" entries. >> >> On my machine (Running Fedora 27, kernel 4.17.3-100.fc27.x86_64) >> usually the 'description' is a non-empty string, and the 'cores' list >> has at least one entry in it.  But sometimes, very rarely, I'll see an >> entry in the process group list where the 'description' is an empty >> string, the 'user' is the string "?", and the 'cores' list is empty. >> Such an entry looks like this: >> >>    {id="19863",type="process",description="",user="?",cores=[]} >> >> I believe that this is caused by the process exiting while GDB is >> scanning /proc for process information.  The current code in >> gdb/nat/linux-osdata.c is not (I think) resilient against exiting >> processes. >> >> This commit adjusts the regex that matches the 'cores' list so that an >> empty list is acceptable, with this patch in place the test script >> gdb.mi/list-thread-groups-available.exp never fails for me now. >> >> gdb/testsuite/ChangeLog: >> >>     * gdb.mi/list-thread-groups-available.exp: Update test regexp. >> --- >>  gdb/testsuite/ChangeLog                               | 4 ++++ >>  gdb/testsuite/gdb.mi/list-thread-groups-available.exp | 2 +- >>  2 files changed, 5 insertions(+), 1 deletion(-) >> >> diff --git a/gdb/testsuite/gdb.mi/list-thread-groups-available.exp >> b/gdb/testsuite/gdb.mi/list-thread-groups-available.exp >> index c4dab2a2c34..88f9ee9b63d 100644 >> --- a/gdb/testsuite/gdb.mi/list-thread-groups-available.exp >> +++ b/gdb/testsuite/gdb.mi/list-thread-groups-available.exp >> @@ -45,7 +45,7 @@ set id_re "id=\"$decimal\"" >>  set type_re "type=\"process\"" >>  set description_re "description=\"$string_re\"" >>  set user_re "user=\"$string_re\"" >> -set cores_re "cores=\\\[\"$decimal\"(,\"$decimal\")*\\\]" >> +set cores_re "cores=\\\[(\"$decimal\"(,\"$decimal\")*)?\\\]" >> >>  # List all available processes. >>  set process_entry_re >> "{${id_re},${type_re}(,$description_re)?(,$user_re)?(,$cores_re)?}" > > Hi Andrew, > > The patch LGTM.  I manually reproduced this case by spawning a process (tail -f /dev/null) and noting its pid.  In linux_xfer_osdata_processes, I added: > >   if (pid == ) >     sleep (5); > > and killing the process during that sleep. But shouldn't we make GDB handle this better? Make the output more "atomic" in the sense that we either show a valid complete entry, or no entry? There's an inherent race here, since we use multiple /proc accesses to fill up a process entry. If we start fetching process info for a process, and the process disappears midway, I'd think it better to discard that process's entry, as-if we had not even seen it, i.e., as if we had listed the set of processes a tiny moment later. Thanks, Pedro Alves