Subject: bug#76997: 31.0.50; Freplace_buffer_contents

From: nat chapman <[email-masked]>
Date: Thu, 13 Mar 2025 16:27:13 +0000

under certain circumstances, Freplace_buffer_contents seems to introduce
gibberish into the buffer. i noticed it in org-mode and followed it to
Freplace_buffer_contents with debug, then confirmed with git bisect that
commit 40d8650d517 introduced the problem.

emacs -Q
C-x b test RET
M-x org-mode RET

#+begin_src emacs-lisp
(+ 1 2|)
#+end_src

with point at |, two or three RET begins introducing garbage into the
buffer. sometimes this crashes emacs, but i think that's to do with the
garbage getting read. this copy of emacs was built without x to make the
bisect faster, but i can reproduce it in my normal build of master with
pgtk as well. in my initial testing i saw various different characters,
but in this test build it's consistently ^@. not sure if that is helpful
information, since the initial testing had different CFLAGS.

emacs -Q --eval "(funcall (kmacro \"C-x b t e s t RET M-x o r g - m o \
d e RET # + b e g i n _ s r c SPC e m a c s - l i s p RET # + e n d _ \
s r c C-p C-e RET ( + SPC 1 SPC 2 ) C-b RET RET RET RET RET RET RET \RET RET\"))"

In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu) of 2025-03-13 built
on hmslydia
Repository revision: f9d805cef3ef9a9818ef09e77c4379d23c2afb55
Repository branch: makepkg
System Description: Arch Linux

Configured using:
'configure -C --sysconfdir=/etc --prefix=/usr --libexecdir=/usr/lib
--localstatedir=/var --without-all --without-x
--with-native-compilation=no 'CFLAGS=-march=x86-64 -mtune=generic -O2
-pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat
-Werror=format-security -fstack-clash-protection -fcf-protection
-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -flto=auto'
'LDFLAGS=-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro
-Wl,-z,now -Wl,-z,pack-relative-relocs -flto=auto'
'CXXFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions
-Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security
-fstack-clash-protection -fcf-protection -fno-omit-frame-pointer
-mno-omit-leaf-frame-pointer -Wp,-D_GLIBCXX_ASSERTIONS -flto=auto''

Configured features:
GMP PDUMPER SECCOMP XIM

Important settings:
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
xterm-mouse-mode: t
tooltip-mode: t
global-eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
minibuffer-regexp-mode: t
line-number-mode: t
indent-tabs-mode: t
transient-mark-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow regexp-opt sort mail-extr emacsbug lisp-mnt message mailcap
yank-media puny dired dnd dired-loaddefs rfc822 mml mml-sec
password-cache epa derived epg rfc6068 epg-config gnus-util
text-property-search mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils image time-date subr-x cl-loaddefs cl-lib
xt-mouse term/xterm xterm byte-opt gv bytecomp byte-compile rmc
iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode tabulated-list replace newcomment
text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow
isearch easymenu timer select mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote multi-tty make-network-process
tty-child-frames emacs)

Memory information:
((conses 16 53189 9736) (symbols 48 6222 0) (strings 32 15038 1609)
(string-bytes 1 377042) (vectors 16 7809) (vector-slots 8 69139 5730)
(floats 8 43 29) (intervals 56 376 0) (buffers 984 12))