Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Philippe Blain via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Cc: Louis-He <1726110778@qq.com>,
	Dominique Quatravaux <dominique.quatravaux@epfl.ch>,
	Sam Warner <samuuel.r.warner@me.com>
Subject: [RFC][PATCH v2 0/2][PR gdb/24069] Fix GDB hang on macOS 10.14 and later (PR gdb/24609)
Date: Wed, 16 Feb 2022 09:15:38 -0500	[thread overview]
Message-ID: <20220216141540.96514-1-levraiphilippeblain@gmail.com> (raw)
In-Reply-To: <20210408191449.27434-1-dominique.quatravaux@epfl.ch>

Hello, this is a rebased version of Dominique Quatravaux's patches from April
2021 [1] (also at [2]) relating to PR gdb/24609.

The first patch of that series was commited in 83a559f7b93 (Remove unused
variable un darwin_nat_target::resume, 2021-04-08), so it's omitted here.

1/2 is thus Dominique's 2nd patch, ans 2/2 Dominique's 3rd.

1/2 is unchanged; 2/2 is mostly the re-worked version that Louis posted as an
attachment on Bugzilla recently [3], [4]. I've kept Dominique as author
and added a "Co-authored-by" trailer for Louis and myself, I hope this is OK
with everyone (and in line with the project's conventions).

Louis, tell me if you'd preferred a different name+email identity be recorded
in the commit message trailer.

The date used in the Changelog entries is current, but I kept the commit dates
to those of Dominiques's v1. Let me know if one or the other should be changed.

The patches are marked RFC because I can't yet show testsuite results. When
manually running GDB compiled with these patches on macOS 10.15, it seems to
work (not hang), although only with 'set startup-with-shell off'. However,
when I run the testsuite, GDB hangs systematically in the 'wait4' call at
gdb/darwin-nat.c:1097, i.e.

    res_pid = wait4 (inf->pid, &wstatus, 0, NULL);

as can be seen by attaching LLDB, and so tests timeout. An exemple run on
GitHub Actions can be found at [5]. On my macOS 10.11 system, this hang does
not happen, with or without the patches. I'm not sure how to go about debugging
this hang when running the test suite... I did try "set debug infrun 1" and
"set debug darwin 12", as Simon suggested in [6], but it did not seem to help
me understand.

A range-diff against v1 is included below.

[1] https://pi.simark.ca/gdb-patches/20210408191449.27434-1-dominique.quatravaux@epfl.ch/t/#u
[2] https://sourceware.org/pipermail/gdb-patches/2021-April/177598.html
[3] https://sourceware.org/bugzilla/attachment.cgi?id=13953
[4] https://pi.simark.ca/gdb-patches/CAE1H+iEug4oQF1ty9tMz9xJUD1kW=6e7ZUuBcXPfuSAxzhFwvA@mail.gmail.com/
[5] https://github.com/phil-blain/binutils-gdb/runs/5114288157?check_suite_focus=true
[6] https://pi.simark.ca/gdb-patches/4bf807c4-d78f-05a4-6cf5-4fa283bc7c1d@simark.ca/

Dominique Quatravaux (2):
  [delete] Not-so-harmless spurious call to `wait4`
  [fix] Skip over WIFSTOPPED wait4 status

 gdb/darwin-nat.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

Range-diff against v1:
1:  faee0c55f49 < -:  ----------- [fix] Unused struct
2:  1aeab1c3e10 ! 1:  1dd0dc08936 [delete] Not-so-harmless spurious call to `wait4`
    @@ Commit message
         commits bb00b29d7802 and a80b95ba67e2 from the 2008-2009 era, but
         fails to answer the “why” question conclusively.
     
    +    ChangeLog:
    +
    +    2022-02-05  Dominique Quatravaux <dominique.quatravaux@epfl.ch>
    +
    +            PR gdb/24609
    +            * gdb/darwin-nat.c (darwin_nat_target::decode_message): Remove
    +            spurious call to wait4.
    +
      ## gdb/darwin-nat.c ##
     @@ gdb/darwin-nat.c: darwin_nat_target::decode_message (mach_msg_header_t *hdr,
      	      inferior_debug (4, _("darwin_wait: pid=%d exit, status=0x%x\n"),
3:  fa02ae8a550 ! 2:  8da6aefb32d [fix] Skip over WIFSTOPPED wait4 status
    @@ Commit message
         - Refactor logging so as to clearly distinguish between the three
         MACH_NOTIFY_DEAD_NAME cases (WIFEXITED, WIFSTOPPED, signal)
     
    +    Co-authored-by: Louis-He <1726110778@qq.com>
    +    Co-authored-by: Philippe Blain <levraiphilippeblain@gmail.com>
    +
    +    ChangeLog:
    +
    +    2022-02-05  Dominique Quatravaux <dominique.quatravaux@epfl.ch>
    +
    +            PR gdb/24609
    +            * gdb/darwin-nat.c (darwin_nat_target::decode_message): Also
    +            check for WIFSTOPPED upon MACH_NOTIFY_DEAD_NAME.
    +
    +
    + ## Notes ##
    +    I hope I did not mess up the indentation here. I did not find any guidelines
    +    about tab width in the C/C++ coding standards [1].
    +
    +    [1] https://sourceware.org/gdb/wiki/Internals%20GDB-C-Coding-Standards#Whitespaces
    +
      ## gdb/darwin-nat.c ##
     @@ gdb/darwin-nat.c: darwin_nat_target::decode_message (mach_msg_header_t *hdr,
          }
        else if (hdr->msgh_id == 0x48)
          {
     -      /* MACH_NOTIFY_DEAD_NAME: notification for exit.  */
    -+      /* MACH_NOTIFY_DEAD_NAME: notification for exit *or* WIFSTOPPED.  */
    ++      /* MACH_NOTIFY_DEAD_NAME: notification for exit *or* WIFSTOPPED. */
            int res;
      
            res = darwin_decode_notify_message (hdr, &inf);
     @@ gdb/darwin-nat.c: darwin_nat_target::decode_message (mach_msg_header_t *hdr,
    - 		{
    - 		  status->kind = TARGET_WAITKIND_EXITED;
    - 		  status->value.integer = WEXITSTATUS (wstatus);
    -+		  inferior_debug (4, _("darwin_wait: pid=%d exit, status=0x%x\n"),
    + 		  return minus_one_ptid;
    + 		}
    + 	      if (WIFEXITED (wstatus))
    +-		status->set_exited (WEXITSTATUS (wstatus));
    ++		{
    ++		  status->set_exited (WEXITSTATUS (wstatus));
    ++	          inferior_debug (4, _("darwin_wait: pid=%d exit, status=0x%x\n"),
     +				  res_pid, wstatus);
     +		}
     +	      else if (WIFSTOPPED (wstatus))
     +		{
    -+		  status->kind = TARGET_WAITKIND_IGNORE;
    -+		  inferior_debug (4, _("darwin_wait: pid %d received WIFSTOPPED\n"), res_pid);
    ++		  status->set_ignore ();
    ++		  inferior_debug (4, _("darwin_wait: pid %d received WIFSTOPPED\n"),
    ++				  res_pid);
     +		  return minus_one_ptid;
    - 		}
    ++		}
      	      else
      		{
    - 		  status->kind = TARGET_WAITKIND_SIGNALLED;
    - 		  status->value.sig = gdb_signal_from_host (WTERMSIG (wstatus));
    + 		  status->set_signalled
    + 		    (gdb_signal_from_host (WTERMSIG (wstatus)));
     +		  inferior_debug (4, _("darwin_wait: pid=%d received signal %d\n"),
    -+			      res_pid, status->value.sig);
    ++				  res_pid, status->sig());
      		}
      
     -	      inferior_debug (4, _("darwin_wait: pid=%d exit, status=0x%x\n"),

base-commit: 0acf434a23768449cbb4b3732355f3f2febecaee
-- 
2.29.2


  parent reply	other threads:[~2022-02-16 14:16 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-08 19:14 [PATCH 1/3] [fix] Unused struct Dominique Quatravaux via Gdb-patches
2021-04-08 19:14 ` [PATCH 2/3] [delete] Not-so-harmless spurious call to `wait4` Dominique Quatravaux via Gdb-patches
2021-04-08 19:26   ` Simon Marchi via Gdb-patches
2021-04-08 20:25     ` [PATCH] was " Dominique Quatravaux via Gdb-patches
2021-04-09 14:34       ` Simon Marchi via Gdb-patches
2021-07-05  2:11         ` Simon Marchi via Gdb-patches
2021-04-08 19:14 ` [PATCH 3/3] [fix] Skip over WIFSTOPPED wait4 status Dominique Quatravaux via Gdb-patches
2021-04-08 19:54   ` Simon Marchi via Gdb-patches
2021-04-08 19:23 ` [PATCH 1/3] [fix] Unused struct Simon Marchi via Gdb-patches
2022-02-16 14:15 ` Philippe Blain via Gdb-patches [this message]
2022-02-16 14:15   ` [RFC][PATCH v2 1/2][PR gdb/24069] [delete] Not-so-harmless spurious call to `wait4` Philippe Blain via Gdb-patches
2022-02-19 15:47     ` Simon Marchi via Gdb-patches
2022-02-19 15:57       ` Philippe Blain via Gdb-patches
2022-02-19 16:02         ` Simon Marchi via Gdb-patches
2022-02-16 14:15   ` [RFC][PATCH v2 2/2][PR gdb/24069] [fix] Skip over WIFSTOPPED wait4 status Philippe Blain via Gdb-patches
2022-02-19 15:59     ` Simon Marchi via Gdb-patches
2022-02-19 17:49       ` Philippe Blain via Gdb-patches
2022-02-16 14:23   ` [RFC][PATCH v2 0/2][PR gdb/24069] Fix GDB hang on macOS 10.14 and later (PR gdb/24609) Philippe Blain via Gdb-patches
2022-02-24 14:23   ` [RFC][PATCH v3 0/1][PR gdb/24069] Fix GDB hang on macOS 10.14 and later Philippe Blain via Gdb-patches
2022-02-24 14:23     ` [RFC][PATCH v3 1/1][PR gdb/24069] gdb/darwin: skip over WIFSTOPPED wait4 status Philippe Blain via Gdb-patches
2022-02-24 15:49       ` Simon Marchi via Gdb-patches
2022-02-28 17:52         ` Philippe Blain via Gdb-patches
2022-02-28 18:34           ` Simon Marchi via Gdb-patches
2022-02-28 18:40             ` Philippe Blain via Gdb-patches

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=20220216141540.96514-1-levraiphilippeblain@gmail.com \
    --to=gdb-patches@sourceware.org \
    --cc=1726110778@qq.com \
    --cc=dominique.quatravaux@epfl.ch \
    --cc=levraiphilippeblain@gmail.com \
    --cc=samuuel.r.warner@me.com \
    /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