[Bug ada/26318] New: gdbtypes.h:526: internal-error: LONGEST dynamic_prop::const_val() const: Assertion `m_kind == PROP_CONST' failed. (ada_modulus))

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug ada/26318] New: gdbtypes.h:526: internal-error: LONGEST dynamic_prop::const_val() const: Assertion `m_kind == PROP_CONST' failed. (ada_modulus))

Sourceware - gdb-prs mailing list
https://sourceware.org/bugzilla/show_bug.cgi?id=26318

            Bug ID: 26318
           Summary: gdbtypes.h:526: internal-error: LONGEST
                    dynamic_prop::const_val() const: Assertion `m_kind ==
                    PROP_CONST' failed. (ada_modulus))
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ada
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

[ Note: this is a different PR than PR26235 - "gdbtypes.h:526: internal-error:
LONGEST dynamic_prop::const_val() const: Assertion `m_kind == PROP_CONST'
failed." ]

With gcc-10, we run into:
...
$ gdb -batch ./outputs/gdb.ada/access_to_packed_array/foo -ex "maint
expand-symtabs" -ex "maint print symbols"
  ...
src/gdb/gdbtypes.h:526: internal-error: LONGEST dynamic_prop::const_val()
const: Assertion `m_kind == PROP_CONST' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
...

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug ada/26318] gdbtypes.h:526: internal-error: LONGEST dynamic_prop::const_val() const: Assertion `m_kind == PROP_CONST' failed. (ada_modulus))

Sourceware - gdb-prs mailing list
https://sourceware.org/bugzilla/show_bug.cgi?id=26318

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simark at simark dot ca

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
m_kind value at assert:
...
(gdb) p m_kind
$1 = PROP_LOCLIST
...

Backtrace:
...
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff4d9cb01 in __GI_abort () at abort.c:79
#2  0x0000000000a65833 in dump_core () at
/home/vries/gdb_versions/devel/src/gdb/utils.c:204
#3  0x0000000000a65d44 in internal_vproblem(internal_problem *, const char *,
int, const char *, typedef __va_list_tag __va_list_tag *) (problem=0x1540360
<internal_error_problem>,
    file=0xd3ea98 "/home/vries/gdb_versions/devel/src/gdb/gdbtypes.h",
line=526,
    fmt=0xd3ea3c "%s: Assertion `%s' failed.", ap=0x7fffffffd078)
    at /home/vries/gdb_versions/devel/src/gdb/utils.c:414
#4  0x0000000000a65e08 in internal_verror (
    file=0xd3ea98 "/home/vries/gdb_versions/devel/src/gdb/gdbtypes.h",
line=526,
    fmt=0xd3ea3c "%s: Assertion `%s' failed.", ap=0x7fffffffd078)
    at /home/vries/gdb_versions/devel/src/gdb/utils.c:439
#5  0x0000000000cefb6b in internal_error (
    file=0xd3ea98 "/home/vries/gdb_versions/devel/src/gdb/gdbtypes.h",
line=526,
    fmt=0xd3ea3c "%s: Assertion `%s' failed.")
    at /home/vries/gdb_versions/devel/src/gdbsupport/errors.cc:55
#6  0x000000000044b15f in dynamic_prop::const_val (this=0x2543cb0)
    at /home/vries/gdb_versions/devel/src/gdb/gdbtypes.h:526
#7  0x00000000004457d7 in ada_modulus (type=0x2543c20)
    at /home/vries/gdb_versions/devel/src/gdb/ada-lang.c:11455
#8  0x000000000045d6e1 in ada_print_type (type0=0x2543c20,
--Type <RET> for more, q to quit, c to continue without paging--c
    varstring=0x25ee290 "<interfaces__c__to_c__B_25__TTrSP1__2___XDL_0>",
stream=0x21de870, show=1, level=5, flags=0xe7af60 <type_print_raw_options>) at
/home/vries/gdb_versions/devel/src/gdb/ada-typeprint.c:1037
#9  0x000000000044cadd in ada_language::print_type (this=0x15aa240
<ada_language_defn>, type=0x2543c20, varstring=0x25ee290
"<interfaces__c__to_c__B_25__TTrSP1__2___XDL_0>", stream=0x21de870, show=1,
level=5, flags=0xe7af60 <type_print_raw_options>) at
/home/vries/gdb_versions/devel/src/gdb/ada-lang.c:13905
#10 0x00000000009a3418 in print_symbol (gdbarch=0x21fa480, symbol=0x2543d20,
depth=5, outfile=0x21de870) at
/home/vries/gdb_versions/devel/src/gdb/symmisc.c:584
#11 0x00000000009a271a in dump_symtab_1 (symtab=0x244bd30, outfile=0x21de870)
at /home/vries/gdb_versions/devel/src/gdb/symmisc.c:353
#12 0x00000000009a2921 in dump_symtab (symtab=0x244bd30, outfile=0x21de870) at
/home/vries/gdb_versions/devel/src/gdb/symmisc.c:411
#13 0x00000000009a2fe8 in maintenance_print_symbols (args=0x0, from_tty=0) at
/home/vries/gdb_versions/devel/src/gdb/symmisc.c:520
#14 0x000000000053ef1a in do_const_cfunc (c=0x1ebb2d0, args=0x0, from_tty=0) at
/home/vries/gdb_versions/devel/src/gdb/cli/cli-decode.c:95
#15 0x00000000005425a4 in cmd_func (cmd=0x1ebb2d0, args=0x0, from_tty=0) at
/home/vries/gdb_versions/devel/src/gdb/cli/cli-decode.c:2181
#16 0x00000000009fa029 in execute_command (p=0x7fffffffe1df "", from_tty=0) at
/home/vries/gdb_versions/devel/src/gdb/top.c:668
#17 0x000000000078fab2 in catch_command_errors (command=0x9f9ab0
<execute_command(char const*, int)>, arg=0x7fffffffe1cc "maint print symbols",
from_tty=0) at /home/vries/gdb_versions/devel/src/gdb/main.c:457
#18 0x0000000000790e85 in captured_main_1 (context=0x7fffffffdaf0) at
/home/vries/gdb_versions/devel/src/gdb/main.c:1218
#19 0x0000000000791075 in captured_main (data=0x7fffffffdaf0) at
/home/vries/gdb_versions/devel/src/gdb/main.c:1243
#20 0x00000000007910e0 in gdb_main (args=0x7fffffffdaf0) at
/home/vries/gdb_versions/devel/src/gdb/main.c:1268
#21 0x00000000004175e9 in main (argc=12, argv=0x7fffffffdbf8) at
/home/vries/gdb_versions/devel/src/gdb/gdb.c:32
...

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug ada/26318] gdbtypes.h:526: internal-error: LONGEST dynamic_prop::const_val() const: Assertion `m_kind == PROP_CONST' failed. (ada_modulus)

Sourceware - gdb-prs mailing list
In reply to this post by Sourceware - gdb-prs mailing list
https://sourceware.org/bugzilla/show_bug.cgi?id=26318

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|gdbtypes.h:526:             |gdbtypes.h:526:
                   |internal-error: LONGEST     |internal-error: LONGEST
                   |dynamic_prop::const_val()   |dynamic_prop::const_val()
                   |const: Assertion `m_kind == |const: Assertion `m_kind ==
                   |PROP_CONST' failed.         |PROP_CONST' failed.
                   |(ada_modulus))              |(ada_modulus)

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug ada/26318] gdbtypes.h:526: internal-error: LONGEST dynamic_prop::const_val() const: Assertion `m_kind == PROP_CONST' failed. (ada_modulus)

Sourceware - gdb-prs mailing list
In reply to this post by Sourceware - gdb-prs mailing list
https://sourceware.org/bugzilla/show_bug.cgi?id=26318

--- Comment #2 from Simon Marchi <simark at simark dot ca> ---
I can't reproduce.  I have:

$ gnat --version
GNAT 10.1.0
$ gcc --version
gcc (GCC) 10.1.0

I do this to generate the test binary:

$ make check TESTS="gdb.ada/access_to_packed_array.exp"

and this to try to trigger the bug:

$ ./gdb -batch ./testsuite/outputs/gdb.ada/access_to_packed_array/foo -ex
"maint expand-symtabs" -ex "maint print symbols"

and it doesn't trigger.

As it happened in the past, I'm guessing that it's because my distribution
doesn't include debug info for the Ada standard lib.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug ada/26318] gdbtypes.h:526: internal-error: LONGEST dynamic_prop::const_val() const: Assertion `m_kind == PROP_CONST' failed. (ada_modulus)

Sourceware - gdb-prs mailing list
In reply to this post by Sourceware - gdb-prs mailing list
https://sourceware.org/bugzilla/show_bug.cgi?id=26318

--- Comment #3 from Simon Marchi <simark at simark dot ca> ---
Ok, I managed to reproduce it using an openSUSE container.  I'll attach the
file here, it might help others reproduce it.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug ada/26318] gdbtypes.h:526: internal-error: LONGEST dynamic_prop::const_val() const: Assertion `m_kind == PROP_CONST' failed. (ada_modulus)

Sourceware - gdb-prs mailing list
In reply to this post by Sourceware - gdb-prs mailing list
https://sourceware.org/bugzilla/show_bug.cgi?id=26318

--- Comment #4 from Simon Marchi <simark at simark dot ca> ---
Created attachment 12734
  --> https://sourceware.org/bugzilla/attachment.cgi?id=12734&action=edit
Reproducer

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug ada/26318] gdbtypes.h:526: internal-error: LONGEST dynamic_prop::const_val() const: Assertion `m_kind == PROP_CONST' failed. (ada_modulus)

Sourceware - gdb-prs mailing list
In reply to this post by Sourceware - gdb-prs mailing list
https://sourceware.org/bugzilla/show_bug.cgi?id=26318

--- Comment #5 from Simon Marchi <simark at simark dot ca> ---
Patch posted here:

https://sourceware.org/pipermail/gdb-patches/2020-July/170962.html

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug ada/26318] gdbtypes.h:526: internal-error: LONGEST dynamic_prop::const_val() const: Assertion `m_kind == PROP_CONST' failed. (ada_modulus)

Sourceware - gdb-prs mailing list
In reply to this post by Sourceware - gdb-prs mailing list
https://sourceware.org/bugzilla/show_bug.cgi?id=26318

--- Comment #6 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Simon Marchi <[hidden email]>:

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

commit 5e500d33230ce2683001038177ad335365764793
Author: Simon Marchi <[hidden email]>
Date:   Thu Jul 30 14:56:08 2020 -0400

    gdb: handle non-const property types in ada_modulus (PR ada/26318)

    PR 26318 shows that running `maint print symbols` on an Ada binary,
    compiled with an Ada distribution that includes debug info for the
    standard library, triggers this assertion:

        /home/simark/src/binutils-gdb/gdb/gdbtypes.h:526: internal-error:
LONGEST dynamic_prop::const_val() const: Assertion `m_kind == PROP_CONST'
failed.

    The problem is in particular when printing type
    `system__object_reader__decoded_ada_name__TTdecodedSP1___XDL_0`, which
    has a dynamic high bound (PROP_LOCLIST kind).  When printing a concrete
    value of this type, this type gets resolved to a type with a constant
    high bound, so ada_modulus can return this constant value.

    However, when printing the dynamic range type on its own, such as with
    `maint print symbols`, the high bound is still of kind PROP_LOCLIST.
    When ada_modulus tries to access the property as a const value, the
    assert triggers.

    There's no sensible numerical value to return in this case.  Ideally,
    ada_modulus would return something to the caller indicating that the
    value is dynamic and therefore can't be returned as an integer.  The
    callers would handle it, for example `maint print symbols` would say
    that the high bound of the type is dynamic.

    However, this patch implements the simpler fix of returning 0 in that
    case.  It kind of restores the previous behavior of before we validated
    the dynamic property kind in the getters, where we would just return
    whatever random integer value was in `const_val`.  Except now it's
    consistently 0.

    This is what we had before we added dynamic property getters:

    $ ./gdb -q ~/foo -ex "maint expand-symtabs" -ex "maint print symbols"
-batch | grep 'typedef <system__object_reader__decoded_ada_name__TTdecodedSP1'
         typedef <system__object_reader__decoded_ada_name__TTdecodedSP1: mod
107820865988257;

    and this is what we have now:

    $ ./gdb -q ~/foo -ex "maint expand-symtabs" -ex "maint print symbols"
-batch | grep 'typedef <system__object_reader__decoded_ada_name__TTdecodedSP1'
         typedef <system__object_reader__decoded_ada_name__TTdecodedSP1: mod 0;

    The value 107820865988257 is the `baton` field of the property's union
    interpreted as an integer, so a bogus value.

    gdb/ChangeLog:

            PR ada/26318
            * ada-lang.c (ada_modulus): Return 0 if property is not of const
            kind.

    Change-Id: I3f6d343a9c3cd7cd62a4fc591943a43541223d50

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug ada/26318] gdbtypes.h:526: internal-error: LONGEST dynamic_prop::const_val() const: Assertion `m_kind == PROP_CONST' failed. (ada_modulus)

Sourceware - gdb-prs mailing list
In reply to this post by Sourceware - gdb-prs mailing list
https://sourceware.org/bugzilla/show_bug.cgi?id=26318

Simon Marchi <simark at simark dot ca> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #7 from Simon Marchi <simark at simark dot ca> ---
Fixed by patch above.

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