Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Stephan Rohr <stephan.rohr@intel.com>
To: gdb-patches@sourceware.org
Cc: guinevere@redhat.com
Subject: [PATCH vv2 1/1] gdb: fix assert after register write failure
Date: Thu, 15 Oct 2026 14:11:27 +0000	[thread overview]
Message-ID: <20261015141127.152846-2-stephan.rohr@intel.com> (raw)
In-Reply-To: <20261015141127.152846-1-stephan.rohr@intel.com>

From: Eduard Sargsyan <eduard.sargsyan@intel.com>

GDB tries to invalidate register cache if write to register fails.  In case
when write was requested to be done for a remote inferior and connection with
remote is dead (so write request will fail) GDB cleans register caches and as
result setting register status fails with segmentation fault, because internal
pointers are not valid anymore and the unique_ptr with register status is
null.

This change adds check if register status cache is still valid before trying to
modify (set status to UNKNOWN).
---
 gdb/regcache.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gdb/regcache.c b/gdb/regcache.c
index 773e8ac37d0..723a2759d1c 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -329,7 +329,8 @@ void
 reg_buffer::invalidate (int regnum)
 {
   assert_regnum (regnum);
-  m_register_status[regnum] = REG_UNKNOWN;
+  if (m_register_status != nullptr)
+    m_register_status[regnum] = REG_UNKNOWN;
 }
 
 void
-- 
2.43.0

________________________________________
Intel Deutschland GmbH 

Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany 

Tel: +49 (89) 99143-0 

www.intel.de 

Managing Directors: Candice Moore, Jeffrey Schneiderman, Ramachandran Sitaraman

Chairperson of the Supervisory Board: Sonja Pierer

Registered Seat: Munich Commercial Register B: Amtsgericht Munich HRB 186928

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


  reply	other threads:[~2026-10-15 14:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15 14:11 [PATCH v2 0/1] " Stephan Rohr
2026-10-15 14:11 ` Stephan Rohr [this message]
2026-10-19 16:19   ` [PATCH vv2 1/1] " Tom Tromey
2026-10-21 13:47     ` Rohr, Stephan
2026-10-21 17:22       ` 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=20261015141127.152846-2-stephan.rohr@intel.com \
    --to=stephan.rohr@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=guinevere@redhat.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