Re: [PATCH v2 08/17] gdb: convert type instance flags to bitfields
Keith Seitz <[email protected]> Fri, 24 Jul 2026 12:10:57 -0700
| Newsgroups | gmane.comp.gdb.patches |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I know Tom has already approved this, but I want to raise
awareness of a small problem introduced in this patch.
On 7/22/26 3:41 AM, Tankut Baris Aktemur wrote:
> diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
> index 1749c3ba741..11a08428baf 100644
> --- a/gdb/gdbtypes.h
> +++ b/gdb/gdbtypes.h
> @@ -99,51 +99,80 @@ enum harvard_address_space
[snip]
> > -/* Not textual. By default, GDB treats all single byte integers as
> - characters (or elements of strings) unless this flag is set. */
> + type_instance_flags &operator|= (const type_instance_flags &other)
> + {
> + is_const = is_const || other.is_const;
> + is_volatile = is_volatile || other.is_volatile;
> +
> + gdb_assert (harvard_aspace == 0);
> + harvard_aspace = other.harvard_aspace;
>
This assumes the left-hand side is empty, but check_typedef can call
|= when the accumulated (outer) flags already have a Harvard space or
address class set.
Here's a concrete demonstration of the problem:
typedef int myint;
(gdb) ptype (@code myint) 3
../../src/gdb/gdbtypes.h:127: internal-error: operator|=: Assertion
`harvard_aspace == 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
----- Backtrace -----
0x5bb1d1 gdb_internal_backtrace_1
../../src/gdb/bt-utils.c:122
0x5bb210 _Z22gdb_internal_backtracev
../../src/gdb/bt-utils.c:173
0xdfbbaa internal_vproblem
../../src/gdb/utils.c:434
0xdfbf45 _Z15internal_verrorPKciS0_P13__va_list_tag
../../src/gdb/utils.c:514
0x162763f _Z18internal_error_locPKciS0_z
../../src/gdbsupport/errors.cc:57
0x87e8e6 _ZN19type_instance_flagsoRERKS_
../../src/gdb/gdbtypes.h:127
0x875d71 _Z13check_typedefP4type
../../src/gdb/gdbtypes.c:3072
[snip]
The "outer" type (associated with "@code") has an address space
set. When check_typedef then attempts to merge the inner "myint"
definition, the assert triggers.
Keith