Discussion:
[Bug rust/23626] New: gdb crashes in upstream rust nil-enum test
tromey at sourceware dot org
2018-09-10 17:42:25 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23626

Bug ID: 23626
Summary: gdb crashes in upstream rust nil-enum test
Product: gdb
Version: 8.2
Status: NEW
Severity: normal
Priority: P2
Component: rust
Assignee: unassigned at sourceware dot org
Reporter: tromey at sourceware dot org
Target Milestone: ---

I built rustc with my patches to fix enum debug info.
(See https://github.com/rust-lang/rust/pull/54004)

With this patch, the rust "nil-enum.rs" test case causes
a gdb internal error:

$1 = ../../binutils-gdb/gdb/valops.c:2270: internal-error: int
value_union_variant(type*, const gdb_byte*): Assertion `discriminant_prop !=
nullptr' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) [answered Y; input not from terminal]
../../binutils-gdb/gdb/valops.c:2270: internal-error: int
value_union_variant(type*, const gdb_byte*): Assertion `discriminant_prop !=
nullptr' failed.
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-09-10 17:47:22 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23626

--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
The DWARF says:

<2><311>: Abbrev Number: 7 (DW_TAG_structure_type)
<312> DW_AT_name : (indirect string, offset: 0x2ae): ANilEnum
<316> DW_AT_byte_size : 0
<317> DW_AT_alignment : 1
<3><318>: Abbrev Number: 8 (DW_TAG_variant_part)
<3><319>: Abbrev Number: 0


The source says:

enum ANilEnum {}


So basically a pathological case not accounted for at some spot in the
gdb variant part code.
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-09-11 21:07:24 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23626

Tom Tromey <tromey at sourceware dot org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at sourceware dot org |tromey at sourceware dot org
--
You are receiving this mail because:
You are on the CC list for the bug.
cvs-commit at gcc dot gnu.org
2018-09-13 17:02:59 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23626

--- Comment #2 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom Tromey <***@sourceware.org>:

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

commit 098b2108a2b61531c0bc8ea16854f773083a95d7
Author: Tom Tromey <***@tromey.com>
Date: Tue Sep 11 15:28:04 2018 -0600

Fix crash with empty Rust enum

While testing my Rust compiler patch to fix the DWARF representation
of Rust enums (https://github.com/rust-lang/rust/pull/54004), I found
a gdb crash coming from one of the Rust test cases.

The bug here is that the new variant support in gdb does not handle
the case where there are no variants in the enum.

This patch fixes the problem in a straightforward way. Note that the
new tests are somewhat lax because I did not want to try to fully fix
this corner case for older compilers. If you think that's
unacceptable, let meknow.

Tested on x86-64 Fedora 28 using several versions of the Rust
compiler. I intend to push this to the 8.2 branch as well.

gdb/ChangeLog
2018-09-13 Tom Tromey <***@tromey.com>

PR rust/23626:
* rust-lang.c (rust_enum_variant): Now static.
(rust_empty_enum_p): New function.
(rust_print_enum, rust_evaluate_subexp, rust_print_struct_def):
Handle empty enum.

gdb/testsuite/ChangeLog
2018-09-13 Tom Tromey <***@tromey.com>

PR rust/23626:
* gdb.rust/simple.rs (EmptyEnum): New type.
(main): Use it.
* gdb.rust/simple.exp (test_one_slice): Add empty enum test.
--
You are receiving this mail because:
You are on the CC list for the bug.
cvs-commit at gcc dot gnu.org
2018-09-13 17:09:43 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23626

--- Comment #3 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The gdb-8.2-branch branch has been updated by Tom Tromey
<***@sourceware.org>:

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

commit 18a27702320ec98fa79a75acd6365ea2348f8852
Author: Tom Tromey <***@tromey.com>
Date: Tue Sep 11 15:28:04 2018 -0600

Fix crash with empty Rust enum

While testing my Rust compiler patch to fix the DWARF representation
of Rust enums (https://github.com/rust-lang/rust/pull/54004), I found
a gdb crash coming from one of the Rust test cases.

The bug here is that the new variant support in gdb does not handle
the case where there are no variants in the enum.

This patch fixes the problem in a straightforward way. Note that the
new tests are somewhat lax because I did not want to try to fully fix
this corner case for older compilers. If you think that's
unacceptable, let meknow.

Tested on x86-64 Fedora 28 using several versions of the Rust
compiler. I intend to push this to the 8.2 branch as well.

2018-09-13 Tom Tromey <***@tromey.com>

PR rust/23626:
* rust-lang.c (rust_enum_variant): Now static.
(rust_empty_enum_p): New function.
(rust_print_enum, rust_evaluate_subexp, rust_print_struct_def):
Handle empty enum.

gdb/testsuite/ChangeLog
2018-09-13 Tom Tromey <***@tromey.com>

PR rust/23626:
* gdb.rust/simple.rs (EmptyEnum): New type.
(main): Use it.
* gdb.rust/simple.exp (test_one_slice): Add empty enum test.
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-09-13 17:18:30 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23626

Tom Tromey <tromey at sourceware dot org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |8.2.1

--- Comment #4 from Tom Tromey <tromey at sourceware dot org> ---
Fixed.
--
You are receiving this mail because:
You are on the CC list for the bug.
Loading...