Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Firmiana <firmiana402@gmail.com>,
	Guinevere Larsen <guinevere@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH][PR gdb/34239][PR gdb/34299] gdb: Check bounds before reading DWARF expression operands
Date: Fri, 26 Jun 2026 10:30:46 -0400	[thread overview]
Message-ID: <7efeed5a-415c-4b39-ad3f-b2f893974c04@simark.ca> (raw)
In-Reply-To: <CADzhaFzR1uv=Z3J2JVcLz7q0onZYykD9bF-+OEpg61un-R+D8w@mail.gmail.com>



On 2026-06-26 04:31, Firmiana wrote:
> 
> Hi,
> 
> Thanks for the review and for testing the patch.
> 
> Before preparing v2, I would like to respond to a few points.
> 
> About the safe_read_* helper implementation: yes, your understanding is
> right.  The helper saves the original pointer, advances through
> safe_skip_bytes to validate that the requested byte range is available,
> and only then calls extract_*_integer on the saved pointer.  I agree that
> this was not obvious enough, so I will make the helper comments and/or
> implementation clearer in v2.
> 
> On the question of reading into `uoffset` and then assigning to the real
> destination: that was mainly done to mirror the nearby
> safe_read_uleb128/safe_read_sleb128 helper style, which uses fixed output
> types and output pointer parameters.  Based on your comment and the other
> review, I plan to change the new fixed-width helpers to use references,
> probably templated, so many call sites can read directly into `result`,
> `this->m_len`, or the relevant field.

The GDB code used to be C, and is now organically evolving into C++.
When you find some opportunities to use some C++ constructs to make the
code better, feel free to do so.

> For DW_OP_deref_size / DW_OP_deref_type: the v1 code is intended to be
> equivalent to:
> 
>   addr_size = *op_ptr;
>   op_ptr++;
> 
> but with a bounds check first.  safe_read_unsigned_integer keeps the
> original pointer for extract_unsigned_integer and uses safe_skip_bytes to
> validate and compute the next pointer.  Since this was confusing, I will
> rewrite the branch more explicitly in v2.
> 
> I will also switch the testcase loop to foreach_with_prefix.

Good idea.

Simon

  reply	other threads:[~2026-06-26 14:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-18 18:01 Jielun Wu
2026-06-23 18:56 ` Guinevere Larsen
2026-06-26  8:31   ` Firmiana
2026-06-26 14:30     ` Simon Marchi [this message]
2026-06-25 15:23 ` Simon Marchi
2026-06-25 16:36 ` Simon Marchi
2026-06-26  7:34   ` Firmiana
2026-06-26 14:23     ` Simon Marchi

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=7efeed5a-415c-4b39-ad3f-b2f893974c04@simark.ca \
    --to=simark@simark.ca \
    --cc=firmiana402@gmail.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