]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb] Fix assertion failure for checkpoint delete 0
authorTom de Vries <tdevries@suse.de>
Wed, 10 Jan 2024 10:27:34 +0000 (11:27 +0100)
committerTom de Vries <tdevries@suse.de>
Wed, 10 Jan 2024 10:27:34 +0000 (11:27 +0100)
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.

Approved-By: Kevin Buettner <kevinb@redhat.com>
PR gdb/31209
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31209

gdb/linux-fork.c
gdb/testsuite/gdb.base/checkpoint.exp

index 659264ab712922cbacf2f96e18d1004b98027fcd..64b83e79204022986f623b6fac5391448567f0bc 100644 (file)
@@ -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
index 9ba5b3e82ec3cc1df05e85fa86a3e86edae4f8ad..96976bb92d24ccaddfd71a4c8fe33f661bed877a 100644 (file)
@@ -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 .*"
+    gdb_test "delete checkpoint 0" "Killed process $decimal"
+    gdb_test "info checkpoints" [string_to_regexp "No checkpoints."]
+}