public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] dwarf2: Fix  dwarf stack fetch array view size mismatch
@ 2022-08-08 11:24 Denis Lukianov
  2022-08-18 16:27 ` Simon Marchi
  0 siblings, 1 reply; 7+ messages in thread
From: Denis Lukianov @ 2022-08-08 11:24 UTC (permalink / raw)
  To: gdb-patches; +Cc: simon.marchi, andrew.burgess

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;


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-08-21 14:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-08 11:24 [PATCH] dwarf2: Fix dwarf stack fetch array view size mismatch Denis Lukianov
2022-08-18 16:27 ` Simon Marchi
2022-08-19 21:33   ` Denis Lukianov
2022-08-20  0:55     ` Simon Marchi
2022-08-20  1:38       ` Denis Lukianov
2022-08-20  1:55         ` Denis Lukianov
2022-08-21 14:17           ` Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).