Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdb: do not hide a lost connection in print_stack_frame
@ 2026-11-06 18:48 Josip Seketa
  0 siblings, 0 replies; only message in thread
From: Josip Seketa @ 2026-11-06 18:48 UTC (permalink / raw)
  To: gdb-patches

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-06 18:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-06 18:48 [PATCH] gdb: do not hide a lost connection in print_stack_frame Josip Seketa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox