From: Mohamed Bouhaouel <mohamed.bouhaouel@intel.com>
To: gdb-patches@sourceware.org
Cc: mohamed.bouhaouel@intel.com, stephan.rohr@intel.com,
markus.t.metzger@intel.com
Subject: [PATCH 02/11] gdb, remote: fix assertion on reconnect to non-stop target
Date: Mon, 18 May 2026 20:32:58 +0200 [thread overview]
Message-ID: <20260518183316.127043-3-mohamed.bouhaouel@intel.com> (raw)
In-Reply-To: <20260518183316.127043-1-mohamed.bouhaouel@intel.com>
From: "Bouhaouel, Mohamed" <mohamed.bouhaouel@intel.com>
When reconnecting to a non-stop remote target, threads may retain stale
internal state from the previous connection (e.g., THREAD_INT_RUNNING).
This causes an assertion failure in
thread_info::set_pending_waitstatus(), which requires the thread to be
in THREAD_INT_STOPPED or THREAD_INT_RESUMED_PENDING_STATUS state.
Fix by setting thread's states before calling set_pending_waitstatus ()
in process_initial_stop_replies ().
Scenario:
- Connect to non-stop remote target with running threads.
- Disconnect (threads remain in THREAD_INT_RUNNING state).
- Reconnect to same target.
- process_initial_stop_replies() processes stop events.
- Assertion fails when trying to set pending waitstatus on thread still
marked as THREAD_INT_RUNNING.
---
gdb/remote.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/gdb/remote.c b/gdb/remote.c
index 735774903f3..4bdbf4aeb08 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -5237,12 +5237,13 @@ remote_target::process_initial_stop_replies (int from_tty)
ws.set_stopped (sig);
}
+ set_internal_state (this, event_ptid, THREAD_INT_STOPPED);
+ set_state (this, event_ptid, THREAD_STOPPED);
+
if (ws.kind () != TARGET_WAITKIND_STOPPED
|| ws.sig () != GDB_SIGNAL_0)
evthread->set_pending_waitstatus (ws);
- set_internal_state (this, event_ptid, THREAD_INT_STOPPED);
- set_state (this, event_ptid, THREAD_STOPPED);
get_remote_thread_info (evthread)->set_not_resumed ();
}
--
2.43.0
Intel Deutschland GmbH
Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany
Tel: +49 89 991 430, www.intel.de
Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell
Chairperson of the Supervisory Board: Nicole Lau
Registered Seat: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
next prev parent reply other threads:[~2026-05-18 18:35 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-18 18:32 [PATCH 00/11] Enable non-stop mode by default for remote targets Mohamed Bouhaouel
2026-05-18 18:32 ` [PATCH 01/11] gdb, record: fix assertion when remote target is set to non-stop Mohamed Bouhaouel
2026-06-10 15:48 ` Andrew Burgess
2026-06-11 15:50 ` Bouhaouel, Mohamed
2026-05-18 18:32 ` Mohamed Bouhaouel [this message]
2026-05-18 18:32 ` [PATCH 03/11] gdb, remote: fix async handler assertion on reconnect to non-stop target Mohamed Bouhaouel
2026-05-18 18:33 ` [PATCH 04/11] gdb, remote: fix "info program" after " Mohamed Bouhaouel
2026-05-18 18:33 ` [PATCH 05/11] gdb, remote: fix crash when accessing removed events Mohamed Bouhaouel
2026-05-18 18:33 ` [PATCH 06/11] gdb, remote: fix ptid matching for process-wide stop events Mohamed Bouhaouel
2026-05-18 18:33 ` [PATCH 07/11] gdb, dap: fix DAP events if no thread is selected Mohamed Bouhaouel
2026-05-18 18:33 ` [PATCH 08/11] gdb, testsuite: handle async close in monitor-exit-quit.exp Mohamed Bouhaouel
2026-05-18 18:33 ` [PATCH 09/11] gdb, testsuite: update attach-deleted-exec.exp to handle async messages Mohamed Bouhaouel
2026-05-18 18:33 ` [PATCH 10/11] gdb, testsuite: add kfails for step-over-process-exit.exp Mohamed Bouhaouel
2026-05-18 18:33 ` [PATCH 11/11] gdb, remote: implement always_non_stop_p for remote target Mohamed Bouhaouel
2026-06-10 11:44 ` PING 01 - [PATCH 00/11] Enable non-stop mode by default for remote targets Bouhaouel, Mohamed
2026-06-12 14:20 ` Pedro Alves
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=20260518183316.127043-3-mohamed.bouhaouel@intel.com \
--to=mohamed.bouhaouel@intel.com \
--cc=gdb-patches@sourceware.org \
--cc=markus.t.metzger@intel.com \
--cc=stephan.rohr@intel.com \
/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