From: Guinevere Larsen <guinevere@redhat.com>
To: Stephan Rohr <stephan.rohr@intel.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: fix assert after register write failure
Date: Thu, 15 Oct 2026 08:49:10 -0300 [thread overview]
Message-ID: <4d285300-6bd0-4445-8b55-425a25e1c771@redhat.com> (raw)
In-Reply-To: <20261012103813.112609-1-stephan.rohr@intel.com>
On 10/12/26 7:38 AM, Stephan Rohr wrote:
> 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).
> ---
Hi! Thanks for working on this!
I wonder if it would be better to move this check to
regcache::invalidate instead, so that we don't need to make this check
every time invalidate is called in this kind of situation.
--
Cheers,
Guinevere Larsen
it/its
she/her (deprecated)
> gdb/regcache.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/regcache.c b/gdb/regcache.c
> index 773e8ac37d0..01c60ea8047 100644
> --- a/gdb/regcache.c
> +++ b/gdb/regcache.c
> @@ -883,8 +883,11 @@ regcache::raw_write (int regnum, gdb::array_view<const gdb_byte> src)
>
> /* Invalidate the register after it is written, in case of a
> failure. */
> - auto invalidator
> - = make_scope_exit ([&] { this->invalidate (regnum); });
> + auto invalidator = make_scope_exit ([&]
> + {
> + if (this->m_register_status != nullptr)
> + this->invalidate (regnum);
> + });
>
> target_store_registers (this, regnum);
>
prev parent reply other threads:[~2026-10-15 11:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 10:38 Stephan Rohr
2026-10-15 11:49 ` Guinevere Larsen [this message]
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=4d285300-6bd0-4445-8b55-425a25e1c771@redhat.com \
--to=guinevere@redhat.com \
--cc=gdb-patches@sourceware.org \
--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