From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B3762385F01C; Sat, 28 Oct 2023 18:34:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B3762385F01C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1698518069; bh=deNXi+6FC4d0oNxTOSwYsV3STJbbu1tkAIX3ccobMx4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=lnDyhU+G8l3PuvmmnqmnrUDtncBYoyiQl1RZx8XBbscIah7st5MELXhbHFEu/yIQ0 PkbdIbjAfWiZKLzMSm2Kqer9wX7d1L+72XUs8IyQST7kn/93Wv9ai9NTxh9lZqrlVU VfaKhRYqsfDeFMk6z6cgivQHV0FPHRGRFaq0SNKw= From: "tpzker at thepuzzlemaker dot info" To: gdb-prs@sourceware.org Subject: [Bug rust/29735] Can't have multiple breakpoints - crash otherwise Date: Sat, 28 Oct 2023 18:34:28 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: rust X-Bugzilla-Version: 12.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tpzker at thepuzzlemaker dot info X-Bugzilla-Status: WAITING X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc attachments.created Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D29735 The Puzzlemaker changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tpzker at thepuzzlemaker d= ot info --- Comment #7 from The Puzzlemaker --- Created attachment 15198 --> https://sourceware.org/bugzilla/attachment.cgi?id=3D15198&action=3Ded= it Patch for this issue, or an issue similar to it I experienced this in 13.2. I believe it's related to the null pointer optimization, or at least the case I encountered was. ``` use std::num::NonZeroUsize; use std::hint::black_box; pub fn main() { foo(black_box(NonZeroUsize::new(5)), black_box(NonZeroUsize::new(5))) } #[inline(never)] pub fn foo(x: Option, y: Option) { black_box(x.unwrap().checked_add(y.unwrap().into())); } ``` Put this in `tmp.rs`. Compile with `rustc tmp.rs -Copt-level=3D1 -Cdebuginfo=3Dfull` Run `gdb tmp::foo` `break foo` `run` `info args` Observe assertion fail: ``` x =3D core::option::Option::Some( ../../gdb/gdbtypes.h:985: internal-error: field: Assertion `idx >=3D 0 && i= dx < num_fields ()' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. ``` This issue is related to this portion of code in `rust_lang::print_enum`: ``` 461 type =3D resolve_dynamic_type (type, view, value_address (val)); ... [snip] 472 int variant_fieldno =3D rust_enum_variant (type); 473 val =3D value_field (val, variant_fieldno); 474 struct type *variant_type =3D type->field (variant_fieldno).type (); ``` https://sourceware.org/git/?p=3Dbinutils-gdb.git;a=3Dblob;f=3Dgdb/rust-lang= .c;h=3D74808ad0716e4d67f6af859f05ebff2b55d5e276;hb=3D662243de0e14a4945555a4= 80dca33c0e677976eb#l461 The type from `resolve_dynamic_type` makes only the variant field of the ac= tive discriminant in active. However, the type of `val` has *all* variant fields enabled, thus making this index meaningless for that. I created a patch for this, which is somewhat hacky--any maintainers here, feel free to change it= up a bit; I am a Rust developer by nature and don't know much about idiomatic = C/++ and in general, what the GDB codebase looks like. Please let me know if you'd like me to test/update this patch to the v14 codebase. --=20 You are receiving this mail because: You are on the CC list for the bug.=