From: Pedro Alves <palves@redhat.com>
To: Simon Marchi <simon.marchi@polymtl.ca>,
Andrew Burgess <andrew.burgess@embecosm.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: Fix instability in thread groups test
Date: Mon, 13 Aug 2018 09:51:00 -0000 [thread overview]
Message-ID: <7da382e5-bd5e-25c2-b3f8-f38e692f35a1@redhat.com> (raw)
In-Reply-To: <d3447a86dc47513f44c82b799330fee6@polymtl.ca>
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="<DECIMAL>",type="process",description="<STRING>",
>> Â Â user="<STRING>",cores=["<DECIMAL>","<DECIMAL>",...]}
>>
>> All the fields after 'id' and 'type' are optional, and the 'cores'
>> list can contain 1 or more "<DECIMAL>" 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 == <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
next prev parent reply other threads:[~2018-08-13 9:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-10 9:58 Andrew Burgess
2018-08-10 21:26 ` Simon Marchi
2018-08-13 9:51 ` Pedro Alves [this message]
2018-08-13 11:41 ` Andrew Burgess
2018-08-13 12:03 ` Pedro Alves
2018-08-13 13:01 ` Andrew Burgess
2018-08-13 13:38 ` Pedro Alves
2018-08-13 21:45 ` [PATCHv2] " Andrew Burgess
2018-08-14 11:37 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7da382e5-bd5e-25c2-b3f8-f38e692f35a1@redhat.com \
--to=palves@redhat.com \
--cc=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).