public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: Tom de Vries <tdevries@suse.de>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] [gdb/dap] Fix exit race
Date: Fri, 23 Feb 2024 10:01:28 -0700	[thread overview]
Message-ID: <87sf1jxggn.fsf@tromey.com> (raw)
In-Reply-To: <20240213150141.28034-1-tdevries@suse.de> (Tom de Vries's message of "Tue, 13 Feb 2024 16:01:41 +0100")

>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> When running test-case gdb.dap/eof.exp, we're likely to get a coredump due to
Tom> a segfault in new_threadstate.

Tom> -                send_gdb("quit")

I think we need a different fix for this.

This patch on its own caused a regression in the internal AdaCore test
suite -- the exit status of gdb is now wrong.  Now, I'm not 100% sure
why this is.  Like, maybe the AdaCore test suite is killing gdb if it
pauses.

However, I thought I'd try to reproduce this in the gdb test suite.  I
wrote the appended.

With this patch in place, dap_shutdown just hangs, which happens because
gdb doesn't exit on its own accord.

I tried adding send_gdb("quit") to Server.main_loop, but of course this
just reintroduces the crash here.  But I tend to think this would be the
right thing to do, and so adding some kind of special case in gdb's
Python layer would be appropriate.

Tom

diff --git a/gdb/testsuite/lib/dap-support.exp b/gdb/testsuite/lib/dap-support.exp
index 72c22d00711..54795a34e39 100644
--- a/gdb/testsuite/lib/dap-support.exp
+++ b/gdb/testsuite/lib/dap-support.exp
@@ -400,6 +400,15 @@ proc dap_check_log_file_re { re } {
 proc dap_shutdown {{terminate false}} {
     dap_check_request_and_response "shutdown" disconnect \
 	[format {o terminateDebuggee [l %s]} $terminate]
+
+    # Check gdb's exit status.
+    global gdb_spawn_id
+    set result [wait -i $gdb_spawn_id]
+    gdb_assert {[lindex $result 2] == 0}
+    gdb_assert {[lindex $result 3] == 0}
+
+    clear_gdb_spawn_id
+
     dap_check_log_file
 }
 

  parent reply	other threads:[~2024-02-23 17:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-13 15:01 Tom de Vries
2024-02-13 18:10 ` Tom Tromey
2024-02-14 15:39   ` Tom de Vries
2024-02-14 15:46     ` Tom Tromey
2024-02-23 17:01 ` Tom Tromey [this message]
2024-02-23 21:08   ` Tom Tromey

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=87sf1jxggn.fsf@tromey.com \
    --to=tromey@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tdevries@suse.de \
    /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).