Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
To: Simon Marchi <simon.marchi@efficios.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 2/4] gdbsupport: add array_view copy function
Date: Mon, 8 Nov 2021 16:11:17 -0500	[thread overview]
Message-ID: <cc7f0ac9-f6ab-d678-3d86-dd2181a61e29@polymtl.ca> (raw)
In-Reply-To: <20211108210609.353208-2-simon.marchi@efficios.com>

On 2021-11-08 4:06 p.m., Simon Marchi wrote:
> From: Simon Marchi <simon.marchi@polymtl.ca>
> 
> An assertion was recently added to array_view::operator[] to ensure we
> don't do out of bounds accesses.  However, when the array_view is copied
> to or from using memcpy, it bypasses this safety.
> 
> To address this, add a `copy` free function that copies data from an
> array view to another.  It ensures that the destination and source array
> views have the same size and element size, which prevents any kind of
> overflow in the source and in the destination.
> 
> I have chosen to allow the array views to have different types, because
> I am thinking we might want to copy arrays of bfd_byte into arrays of
> gdb_byte, for example.
> 
> Change a few randomly selected spots to use the new function, to show
> how it can be used.
> 
> Change-Id: Ibeaca04e0028410fd44ce82f72e60058d6230a03

Hi Tom,

This patch of mine causes the following test failure:

Running /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.ada/packed_array_assign.exp ...
FAIL: gdb.ada/packed_array_assign.exp: print pra(1) := pr (GDB internal error)

I couldn't figure out if this is a mistake on my part, or if my assert points out an
existing bug.  Could you give it a quick look?

The problem is that the values we are copying from and to don't have the same length:

(top-gdb) p toval.type.length
$1 = 5
(top-gdb) p fromval.type.length
$2 = 8

... and that trips on the new assert.

The two values appear to have the same type, so I don't understand where the different
lengths come from.

Simon

  reply	other threads:[~2021-11-08 21:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-08 21:06 [PATCH 1/4] gdb: fix length of array view returned by some value_contents functions Simon Marchi via Gdb-patches
2021-11-08 21:06 ` [PATCH 2/4] gdbsupport: add array_view copy function Simon Marchi via Gdb-patches
2021-11-08 21:11   ` Simon Marchi via Gdb-patches [this message]
2021-11-16 20:54     ` Tom Tromey
2021-11-16 20:53   ` Tom Tromey
2021-11-16 21:56     ` Simon Marchi via Gdb-patches
2021-11-17  0:20       ` Tom Tromey
2021-11-18 20:07         ` Simon Marchi
2021-11-08 21:06 ` [PATCH 3/4] gdb: make extract_integer take an array_view Simon Marchi via Gdb-patches
2021-11-08 21:06 ` [PATCH 4/4] gdb: trivial changes to use array_view Simon Marchi via Gdb-patches
2021-11-16 20:41 ` [PATCH 1/4] gdb: fix length of array view returned by some value_contents functions Tom Tromey
2021-11-16 21:40   ` 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=cc7f0ac9-f6ab-d678-3d86-dd2181a61e29@polymtl.ca \
    --to=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.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