From: Josip Seketa <josip.seketa@gmail.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] gdb: do not hide a lost connection in print_stack_frame
Date: Fri, 06 Nov 2026 18:48:48 +0000 [thread overview]
Message-ID: <179399092827.2913928.12619639377821397955@gmail.com> (raw)
print_stack_frame catches every error. If the remote connection is
lost while it reads the frame, the catch also swallows the
TARGET_CLOSE_ERROR. The target is gone by then, so do_print_stop_event
goes on to call inferior_thread, which fails its assertion:
thread.c:91: internal-error: inferior_thread: Assertion
`current_thread_ != nullptr' failed.
This happens when a stub dies between sending a stop reply and
answering the memory read that prints the stop.
Rethrow TARGET_CLOSE_ERROR, as the error handling in
printcmd.c does, so that the error reaches the user.
---
Found with a stub that dies between a stop reply and the memory read
that prints the stop. Before: rc 134 with the assertion. After:
Program received signal SIGTRAP, Trace/breakpoint trap.
Remote connection closed
with target-async on and off, and in MI. The randomized stub I used
hit this in 5 of 300 runs before the patch, and in none after.
Tested on x86-64 GNU/Linux, with my other pipe patches: gdb.base,
gdb.server, gdb.threads, gdb.mi, gdb.multi and gdb.python on
native-stdio-gdbserver, native-gdbserver and
native-extended-gdbserver, compared with master test by test.
There is no testcase here yet.
I have no FSF copyright assignment.
gdb/stack.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/gdb/stack.c b/gdb/stack.c
index f075db20c..cd6b1de5d 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -407,6 +407,9 @@ print_stack_frame (const frame_info_ptr &frame, int print_level,
}
catch (const gdb_exception_error &e)
{
+ /* The connection is gone: do not hide that from the caller. */
+ if (e.error == TARGET_CLOSE_ERROR)
+ throw;
}
}
--
2.56.0
reply other threads:[~2026-11-06 18:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=179399092827.2913928.12619639377821397955@gmail.com \
--to=josip.seketa@gmail.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