From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
To: Denis Lukianov <denis@voxelsoft.com>, gdb-patches@sourceware.org
Cc: andrew.burgess@embecosm.com
Subject: Re: [PATCH] dwarf2: Fix dwarf stack fetch array view size mismatch
Date: Thu, 18 Aug 2022 12:27:04 -0400 [thread overview]
Message-ID: <beb6001c-3d68-fe9b-a66f-aa56d7dc32ac@polymtl.ca> (raw)
In-Reply-To: <36c80f43b57fcfce3b9db6619e75366db360ae9c.camel@voxelsoft.com>
On 8/8/22 07:24, Denis Lukianov wrote:
> Following change 4bce7cdaf4 "gdbsupport: add array_view copy function",
> dwarf stack fetch sometimes cause an internal-error in
> array_view::copy, where a gdb_assert expects the source and destination
> view sizes to match. When called from dwarf_expr_context::fetch_result
> sometimes the lengths don't match.
>
> Both the source and destination views each have a separate implicit
> length. The source is correctly sliced for the copy. However, the
> destination is passed with the full allocated length, which does not
> necessarily match the source length.
>
> This patch slices the destination to match the source length.
>
> diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
> index 3549745df04..aa203e87bfb 100644
> --- a/gdb/dwarf2/expr.c
> +++ b/gdb/dwarf2/expr.c
> @@ -1025,7 +1025,7 @@ dwarf_expr_context::fetch_result (struct type
> *type, struct type *subobj_type,
> subobj_offset += n - max;
>
> copy (value_contents_all (val).slice (subobj_offset, len),
> - value_contents_raw (retval));
> + value_contents_raw (retval).slice (0, len));
> }
> break;
>
Hi Denis,
Do you have a reproducer for this, that we could turn into a test?
I don't think your change is necessary. retval's content length comes
from the length of `subobj_type`:
retval = allocate_value (subobj_type);
and the variable `len`, used to slice the source view, also comes from
the length of `subobj_type`:
size_t len = TYPE_LENGTH (subobj_type);
So the two views should be of that same length.
Your patch reminded me of a pending patch I had in the same area, which
I just merged:
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=bde195b84a862f31ac111c0881ad13b89ee89492
Maybe you were seeing the same problem as described there?
Simon
next prev parent reply other threads:[~2022-08-18 16:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-08 11:24 Denis Lukianov
2022-08-18 16:27 ` Simon Marchi via Gdb-patches [this message]
2022-08-19 21:33 ` Denis Lukianov
2022-08-20 0:55 ` Simon Marchi via Gdb-patches
2022-08-20 1:38 ` Denis Lukianov
2022-08-20 1:55 ` Denis Lukianov
2022-08-21 14:17 ` Simon Marchi via Gdb-patches
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=beb6001c-3d68-fe9b-a66f-aa56d7dc32ac@polymtl.ca \
--to=gdb-patches@sourceware.org \
--cc=andrew.burgess@embecosm.com \
--cc=denis@voxelsoft.com \
--cc=simon.marchi@polymtl.ca \
/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