Subject: bug#76559: 31.0.50; [-O3 + PGTK] Crash when 'copying as kill'/'killing word'

From: Pip Cet <[email-masked]>
Date: Thu, 27 Feb 2025 11:33:11 +0000

"Po Lu" <[email-masked]> writes:

> Pip Cet <[email-masked]> writes:
>
>> This is strange, but it looks like this may be a C undefined behavior
>> bug (or, less likely, an actual GCC bug).  If the event_kind bitfield is
>> listed with size 4, shouldn't the hole after it be listed with size 4,
>> not size 6?
>
> I'm afraid that must be a Gdb or GCC debuginfo generation bug, since the
> total size of the structure is 56.  Whereas the aggregate of the values
> printed by GDB is 58.

Indeed.  It's probably unrelated.

> Judging by the expression names, it's clearly copying only the `struct
> input_event' union member.  In fact, this erroneous code is generated as
> soon as SRA processes aggregate references.

Yes, SRA seems to be the pass to blame.

> What I suspect is that there is some CU in which `struct
> selection_input_event' is incomplete or fails to appear in `union
> buffered_input_event' and that that misleads the compiler during
> link-time recompilation.  But I could be far off the mark, since I am
> very much out of touch with contemporary GCC.

See my other message.  I'm still puzzled as to why an unsafe cast in one
call path modifies the assumptions made for another call path, but I
guess it all falls under undefined behavior and we should simply apply
that patch and make sure to follow the C standard more closely.

Pip