public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] gdb/linux-nat: use LP's inferior when handling vfork done in linux_handle_extended_wait
Date: Thu, 12 Aug 2021 13:36:13 -0600	[thread overview]
Message-ID: <87a6lmcv6a.fsf@tromey.com> (raw)
In-Reply-To: <20210812154823.966724-1-simon.marchi@polymtl.ca> (Simon Marchi via Gdb-patches's message of "Thu, 12 Aug 2021 11:48:23 -0400")

Simon> I spotted this bug by reading the code and subsequently wrote a test to
Simon> reproduce it.  The bug is caught by the assertions that are added.
Simon> Otherwise the bug wouldn't cause a visible problem, but GDB would still
Simon> be in a wrong state.

This explanation is really great.

Simon> the bug explained above happens and waiting_for_vfork_done stays
Simon> wrongfully set, the assertion will fail when a different event.

The clause after the "," is missing some text, I guess something like
"when a different even is received".

Simon> If I run the test without the fix in linux-nat.c, I get:

Simon>     run^M
Simon>     Starting program: /home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/vfork-multi-inferior/vfork-multi-inferior-vforker ^M
Simon>     [Detaching after vfork from child process 822537]^M
Simon>     /home/simark/src/binutils-gdb/gdb/infrun.c:5255: internal-error: void handle_inferior_event(execution_control_state*): Assertion `!inf->waiting_for_vfork_    done' failed.^M

Looks like some strange word wrapping in here, those spaces before the "done".

Simon>    if (event == PTRACE_EVENT_VFORK_DONE)
Simon>      {
Simon> -      if (current_inferior ()->waiting_for_vfork_done)
Simon> +      inferior *inf = find_inferior_ptid (linux_target, lp->ptid);
Simon> +
Simon> +      if (inf->waiting_for_vfork_done)

I was curious about this and looked, and saw that this is the only use
of current_inferior in this function.  A downside of our globals-based
approach is that it's hard to enforce a rule poisoning this kind of use
here.  Oh well.

Simon> index 000000000000..cb3f3d6abd78
Simon> --- /dev/null
Simon> +++ b/gdb/testsuite/gdb.base/vfork-multi-inferior-other.c
Simon> @@ -0,0 +1,12 @@
Simon> +#include <unistd.h>
Simon> +

I think we normally are sticking the GPL comment in all new files.

Otherwise this all looks reasonable to me.

Tom

  reply	other threads:[~2021-08-12 19:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-12 15:48 Simon Marchi
2021-08-12 19:36 ` Tom Tromey [this message]
2021-08-12 20:33   ` Simon Marchi
2021-08-18 21:05 ` Simon Marchi

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=87a6lmcv6a.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /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).