public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/21356] value.c:828: internal-error: int value_contents_bits_eq(const value*, int, const value*, int, int): Assertion `offset1 + length <= TYPE_LENGTH (val1->enclosing_type) * TARGET_CHAR_BIT' failed
Date: Thu, 11 Jun 2020 12:34:48 +0000	[thread overview]
Message-ID: <bug-21356-4717-UClp2oAbZK@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-21356-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=21356

--- Comment #4 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2f33032a93f24ccc0c0d2f23e2a3ec0442f638d4

commit 2f33032a93f24ccc0c0d2f23e2a3ec0442f638d4
Author: Keith Seitz <keiths@redhat.com>
Date:   Thu Jun 11 14:34:44 2020 +0200

    Compute proper length for dynamic types of TYPE_CODE_TYPEDEF

    This patch fixes gdb/21356 in which we hit an assertion in
    value_contents_bits_eq:

    (gdb) p container_object2
    (gdb) p container_object2
    $1 = {_container_member2 = 15, _vla_struct_object2 = {_some_member = 0,
        _vla_field = {
    ../../src/gdb/value.c:829: internal-error: \
      int value_contents_bits_eq(const value*, int, const value*, int, int): \
      Assertion `offset1 + length \
                 <= TYPE_LENGTH (val1->enclosing_type) * TARGET_CHAR_BIT'
failed.

    This is happening because TYPE_LENGTH (val1->enclosing_type) is erroneously
    based on enclosing_type, which is a typedef, instead of the actual
underlying
    type.

    This can be traced back to resolve_dynamic_struct, where the size of the
    type is computed:
    ...
            TYPE_FIELD_TYPE (resolved_type, i)
              = resolve_dynamic_type_internal (TYPE_FIELD_TYPE (resolved_type,
i),
                                               &pinfo, 0);
            gdb_assert (TYPE_FIELD_LOC_KIND (resolved_type, i)
                        == FIELD_LOC_KIND_BITPOS);

            new_bit_length = TYPE_FIELD_BITPOS (resolved_type, i);
            if (TYPE_FIELD_BITSIZE (resolved_type, i) != 0)
              new_bit_length += TYPE_FIELD_BITSIZE (resolved_type, i);
            else
              new_bit_length += (TYPE_LENGTH (TYPE_FIELD_TYPE (resolved_type,
i))
                                 * TARGET_CHAR_BIT);
    ...

    In this function, resolved_type is TYPE_CODE_TYPEDEF which is not what we
    want to use to calculate the size of the actual field.

    This patch fixes this and the similar problem in resolve_dynamic_union.

    gdb/ChangeLog:
    2020-06-11  Keith Seitz  <keiths@redhat.com>

            PR gdb/21356
            * gdbtypes.c (resolve_dynamic_union, resolve_dynamic_struct):
            Resolve typedefs for type length calculations.

    gdb/testsuite/ChangeLog:
    2020-06-11  Keith Seitz  <keiths@redhat.com>

            PR gdb/21356
            * gdb.base/vla-datatypes.c (vla_factory): Add typedef for struct
            vla_struct.
            Add new struct vla_typedef and union vla_typedef_union and
            corresponding instantiation objects.
            Initialize new objects.
            * gdb.base/vla-datatypes.exp: Add tests for
vla_typedef_struct_object
            and vla_typedef_union_object.
            Fixup type for vla_struct_object.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2020-06-11 12:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-21356-4717@http.sourceware.org/bugzilla/>
2020-06-10 11:42 ` vries at gcc dot gnu.org
2020-06-11 12:34 ` cvs-commit at gcc dot gnu.org [this message]
2020-06-11 12:36 ` vries at gcc dot gnu.org

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=bug-21356-4717-UClp2oAbZK@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).