Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Denis Lukianov <denis@voxelsoft.com>
To: gdb-patches@sourceware.org
Cc: andrew.burgess@embecosm.com
Subject: [PATCH] dwarf2: Fix  dwarf stack fetch array view size mismatch
Date: Mon, 08 Aug 2022 12:24:38 +0100	[thread overview]
Message-ID: <36c80f43b57fcfce3b9db6619e75366db360ae9c.camel@voxelsoft.com> (raw)

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;


             reply	other threads:[~2022-08-08 11:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-08 11:24 Denis Lukianov [this message]
2022-08-18 16:27 ` Simon Marchi via Gdb-patches
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=36c80f43b57fcfce3b9db6619e75366db360ae9c.camel@voxelsoft.com \
    --to=denis@voxelsoft.com \
    --cc=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    /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