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

Previous Next

Package: emacs;

Reported by: Iurie Marian <marian.iurie <at> gmail.com>

Date: Tue, 25 Feb 2025 17:34:01 UTC

Severity: normal

Merged with 76729

Found in version 31.0.50

Full log


Message #122 received at 76559 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: Pip Cet <pipcet <at> protonmail.com>, iura.mail <at> gmail.com,
 Stefan Kangas <stefankangas <at> gmail.com>, michael.albinus <at> gmx.de,
 Eli Zaretskii <eliz <at> gnu.org>, 76559 <at> debbugs.gnu.org, marian.iurie <at> gmail.com
Subject: Re: bug#76559: 31.0.50; [-O3 + PGTK] Crash when 'copying as
 kill'/'killing word'
Date: Sat, 01 Mar 2025 21:43:19 +0800
Paul Eggert <eggert <at> cs.ucla.edu> writes:

> True, the later accessing is undefined as per C23 §6.5.1 ¶7. But the
> patch you proposed still does that sort of accessing, as the code
> still accesses event->kind when event is a union pointer not a struct
> pointer. (Also, the patched code doesn't copy the struct input_event
> on platforms where ! (HAVE_X11 || HAVE_PGTK); I assume that wasn't
> intended.)

Clearly not...

> One littler thing. The pointer cast (even without any further access)
> is undefined as per C23 §6.3.2.3 ¶7 if the original pointer is not
> correctly aligned for the cast's type. Although we have a
> static_assert that the alignment is OK, we don't need that assumption
> or its static_assert if we fix the more-important accessing problem.
>
> So I propose the attached patch instead, to fix the above.

I surmise that it doesn't fix the underlying compiler issue if you add
__attribute__ ((force_inline)) to kbd_buffer_store_buffered_event, as it
is a product of an assumption by GCC's SRA pass that no two accesses of
a single local aggregate declaration with the same offset and size but
of different types alias.  (Mine does, as `struct input_event' and
`struct selection_input_event' are of different sizes, so that the
accesses are not taken to alias.)  Besides, I did not succeed in
convincing the OP's version of GCC's to inline
kbd_buffer_store_buffered_event without expressly directing so despite
having enabled LTO.




This bug report was last modified 109 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.