Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 3/3] [gdb] Fix assertion failure for checkpoint delete 0
Date: Mon,  8 Jan 2024 16:25:53 +0100	[thread overview]
Message-ID: <20240108152553.4578-4-tdevries@suse.de> (raw)
In-Reply-To: <20240108152553.4578-1-tdevries@suse.de>

When doing "checkpoint delete 0" we run into an assertion failure:
...
+delete checkpoint 0
inferior.c:406: internal-error: find_inferior_pid: Assertion `pid != 0' failed.
...

Fix this by handling the "pptid == null_ptid" case in
delete_checkpoint_command.

Tested on x86_64-linux.

PR gdb/31209
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id
---
 gdb/linux-fork.c                      | 11 +++++++++++
 gdb/testsuite/gdb.base/checkpoint.exp | 14 ++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index 659264ab712..64b83e79204 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -537,6 +537,17 @@ Please switch to another checkpoint before deleting the current one"));
 
   delete_fork (ptid);
 
+  if (pptid == null_ptid)
+    {
+      int status;
+      /* Wait to collect the inferior's exit status.  Do not check whether
+	 this succeeds though, since we may be dealing with a process that we
+	 attached to.  Such a process will only report its exit status to its
+	 original parent.  */
+      waitpid (ptid.pid (), &status, 0);
+      return;
+    }
+
   /* If fi->parent_ptid is not a part of lwp but it's a part of checkpoint
      list, waitpid the ptid.
      If fi->parent_ptid is a part of lwp and it is stopped, waitpid the
diff --git a/gdb/testsuite/gdb.base/checkpoint.exp b/gdb/testsuite/gdb.base/checkpoint.exp
index 9ba5b3e82ec..d318fc785b8 100644
--- a/gdb/testsuite/gdb.base/checkpoint.exp
+++ b/gdb/testsuite/gdb.base/checkpoint.exp
@@ -336,3 +336,17 @@ verbose "Timeout now $timeout sec."
 #
 # Finished: cleanup
 #
+
+#
+# Now let's try to delete checkpoint 0.
+#
+
+with_test_prefix "delete checkpoint 0" {
+    clean_restart $binfile
+    runto_main
+
+    gdb_test "checkpoint" "checkpoint 1: fork returned pid $decimal\\."
+    gdb_test "restart 1" "Switching to process $decimal\r\n.*"
+    gdb_test "delete checkpoint 0" "Killed process $decimal"
+    gdb_test "info checkpoints" [string_to_regexp "No checkpoints."]
+}
-- 
2.35.3


  parent reply	other threads:[~2024-01-08 15:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-08 15:25 [PATCH 0/3] [gdb] Two checkpoint fixes Tom de Vries
2024-01-08 15:25 ` [PATCH 1/3] [gdb] Make variable printed bool in info_checkpoints_command Tom de Vries
2024-01-09 17:54   ` Kevin Buettner
2024-01-08 15:25 ` [PATCH 2/3] [gdb] Fix info checkpoints Tom de Vries
2024-01-09 18:03   ` Kevin Buettner
2024-01-08 15:25 ` Tom de Vries [this message]
2024-01-10  5:28   ` [PATCH 3/3] [gdb] Fix assertion failure for checkpoint delete 0 Kevin Buettner
2024-01-10 10:25     ` Tom de Vries

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=20240108152553.4578-4-tdevries@suse.de \
    --to=tdevries@suse.de \
    --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