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


View this message in rfc822 format

From: Po Lu <luangruo <at> yahoo.com>
To: Pip Cet <pipcet <at> protonmail.com>
Cc: Michael Albinus <michael.albinus <at> gmx.de>, Iurie Marian <marian.iurie <at> gmail.com>, 76559 <at> debbugs.gnu.org
Subject: bug#76559: 31.0.50; [-O3 + PGTK] Crash when 'copying as kill'/'killing word'
Date: Thu, 27 Feb 2025 18:13:26 +0800
[Message part 1 (text/plain, inline)]
Po Lu <luangruo <at> yahoo.com> writes:

> 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.

After devoting another 30 minutes to this problem, I've reduced it to a
trivial test case that reveals the same miscompilation under GCC 14.2.1:

[reduction.h (text/plain, attachment)]
[reduction1.c (text/plain, attachment)]
[reduction.c (text/plain, attachment)]
[Message part 5 (text/plain, inline)]
Simply execute:

  $ gcc -fdump-tree-all -fdump-rtl-all -save-temps -O3 -flto -g3 \
    reduction1.c reduction.c -o reduction && ./reduction
  ffffffff

and observe that the high 32 bits of the dpyinfo pointer in the saved
event are truncated, as would be expected from these expressions:

  ev_12 = MEM <unsigned int> [(union buffered_input_event *)&main_inev];

[...]

  MEM <unsigned int> [(union buffered_input_event *)&kbd_buffer] = ev_12;
  MEM <unsigned int> [(union buffered_input_event *)&kbd_buffer + 4B] = ev$ie$code_16;
  MEM <unsigned int> [(union buffered_input_event *)&kbd_buffer + 8B] = ev$ie$modifiers_1;
  MEM <long int> [(union buffered_input_event *)&kbd_buffer + 16B] = ev$ie$device_6;

With aggregate access expansion disabled, all is normal:

  $ gcc -fdump-tree-all -fdump-rtl-all -fno-tree-sra -save-temps \
    -O3 -flto -g3 reduction1.c reduction.c -o reduction && ./reduction
  ffffffffffffffff

In a word, tampering with optimizer options is tantamount to playing
with fire.  Don't do it, if your object is a functioning Emacs.

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.