public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug symtab/31852] New: [gdb/symtab, 1-byte complex float] gdbtypes.c:244: internal-error: new_type: Assertion `(bit % TARGET_CHAR_BIT) == 0' failed
Date: Thu, 06 Jun 2024 14:56:49 +0000	[thread overview]
Message-ID: <bug-31852-4717@http.sourceware.org/bugzilla/> (raw)

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

            Bug ID: 31852
           Summary: [gdb/symtab, 1-byte complex float] gdbtypes.c:244:
                    internal-error: new_type: Assertion `(bit %
                    TARGET_CHAR_BIT) == 0' failed
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: symtab
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

FTR, I wrote the following dwarf assembly test-case:
...
load_lib dwarf.exp

# This test can only be run on targets which support DWARF-2 and use gas.
require dwarf2_support

standard_testfile main.c -debug.S

# Create the DWARF.
set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
    declare_labels unspecified_type_label

    cu { version 2 } {
        compile_unit {} {
            declare_labels int_type

            int_type: DW_TAG_base_type {
                {DW_AT_byte_size 4 DW_FORM_sdata}
                {DW_AT_encoding  @DW_ATE_signed}
                {DW_AT_name int}
            }

            DW_TAG_subprogram {
                {MACRO_AT_func {main}}
                {type :$int_type}
            }

            DW_TAG_base_type {
                {DW_AT_byte_size 1 DW_FORM_sdata}
                {DW_AT_encoding  @DW_ATE_complex_float}
                {DW_AT_name      "complex long double"}
            }
        }
    }
}

if [prepare_for_testing "failed to prepare" $testfile \
        "${asm_file} ${srcfile}" {}] {
    return -1
}

if ![runto_main] {
    return -1
}

gdb_test "ptype complex long double"
...
which produces:
...
 <1><39>: Abbrev Number: 4 (DW_TAG_base_type)
    <3a>   DW_AT_byte_size   : 1
    <3b>   DW_AT_encoding    : 3        (complex float)
    <3c>   DW_AT_name        : complex long double
...

We run into:
...
(gdb) break -qualified main^M
/data/vries/gdb/src/gdb/gdbtypes.c:244: internal-error: new_type: Assertion
`(bit % TARGET_CHAR_BIT) == 0' failed.^M
A problem internal to GDB has been detected,^M
...

Could be fixed by:
...
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c                                    
index f39fe3de6a4..1216b69d67a 100644                                           
--- a/gdb/gdbtypes.c                                                            
+++ b/gdb/gdbtypes.c                                                            
@@ -241,6 +241,8 @@ type_allocator::new_type (enum type_code code, int bit,
const char *name)                         
 {                                                                              
   struct type *type = new_type ();                                             
   set_type_code (type, code);                                                  
+  if (code == TYPE_CODE_ERROR && bit % TARGET_CHAR_BIT != 0)                   
+    bit = 0;                                                                   
   gdb_assert ((bit % TARGET_CHAR_BIT) == 0);                                   
   type->set_length (bit / TARGET_CHAR_BIT);                                    
...

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

                 reply	other threads:[~2024-06-06 14:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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-31852-4717@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).