GNU bug report logs - #79031
31.0.50; Recent change breaks `insert-file-contents-literally'

Previous Next

Package: emacs;

Reported by: Zhengyi Fu <i <at> fuzy.me>

Date: Wed, 16 Jul 2025 13:14:02 UTC

Severity: normal

Found in version 31.0.50

Done: Paul Eggert <eggert <at> cs.ucla.edu>

To reply to this bug, email your comments to 79031 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#79031; Package emacs. (Wed, 16 Jul 2025 13:14:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Zhengyi Fu <i <at> fuzy.me>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 16 Jul 2025 13:14:02 GMT) Full text and rfc822 format available.

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

From: Zhengyi Fu <i <at> fuzy.me>
To: bug-gnu-emacs <at> gnu.org
Cc: Paul Eggert <eggert <at> cs.ucla.edu>
Subject: 31.0.50; Recent change breaks `insert-file-contents-literally'
Date: Wed, 16 Jul 2025 21:13:08 +0800
> commit c3f96d20eecdf0aa93f294a4f3fb96e16eec6a68 (HEAD)
> Author: Paul Eggert <eggert <at> cs.ucla.edu>
> Date:   Sun Jul 13 12:52:43 2025 -0700

>     Avoid some tiny /proc file reads
    
>     * src/fileio.c (union read_non_regular):
>     New members buf and bufsize replace inserted and trytry.
>     (read_non_regular): Adjust to this new, simpler interface.
>     (Finsert_file_contents): If the gap is smaller than read_buf
>     and we want to read more than the gap, read into read_buf
>     first, to avoid lots of tiny reads from /proc files.


After this commit, the following code evaluates to a string of 16384
bytes!

(with-temp-buffer
  (insert-file-contents-literally "/dev/urandom" nil nil 21)
  (buffer-string))



In GNU Emacs 31.0.50 (build 20, x86_64-pc-linux-gnu, GTK+ Version
 3.24.49) of 2025-07-16 built on calliope
Repository revision: 55f41ca3aa8fe487d10730708a7396137a2c9d18
Repository branch: HEAD
System Description: Fedora Linux 42 (Sway)

Configured using:
 'configure --without-all 'CC=ccache gcc' 'CFLAGS=-O0 -g''

Configured features:
GLIB GMP PDUMPER SECCOMP X11 XIM XINERAMA XRANDR GTK3

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

Major mode: Lisp Interaction

Minor modes in effect:
  xterm-mouse-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-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 sort mail-extr emacsbug lisp-mnt message mailcap yank-media puny
dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg
rfc6068 epg-config gnus-util text-property-search time-date subr-x
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader cl-loaddefs cl-lib sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils xt-mouse term/xterm xterm byte-opt gv
bytecomp byte-compile china-util rmc iso-transl tooltip cconv eldoc
paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode
mwheel term/x-win x-win term/common-win x-dnd touch-screen tool-bar dnd
fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow
isearch easymenu timer select scroll-bar 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 dynamic-setting gtk x-toolkit x
multi-tty move-toolbar make-network-process tty-child-frames emacs)

Memory information:
((conses 16 52730 12168) (symbols 48 6171 0) (strings 32 14442 1585)
 (string-bytes 1 353806) (vectors 16 8063)
 (vector-slots 8 120952 7572) (floats 8 26 1) (intervals 56 220 10)
 (buffers 984 10))




Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Wed, 16 Jul 2025 18:48:02 GMT) Full text and rfc822 format available.

Notification sent to Zhengyi Fu <i <at> fuzy.me>:
bug acknowledged by developer. (Wed, 16 Jul 2025 18:48:02 GMT) Full text and rfc822 format available.

Message #10 received at 79031-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Zhengyi Fu <i <at> fuzy.me>
Cc: 79031-done <at> debbugs.gnu.org
Subject: Re: 31.0.50; Recent change breaks `insert-file-contents-literally'
Date: Wed, 16 Jul 2025 11:47:30 -0700
[Message part 1 (text/plain, inline)]
On 2025-07-16 06:13, Zhengyi Fu wrote:
> the following code evaluates to a string of 16384
> bytes!
> 
> (with-temp-buffer
>    (insert-file-contents-literally "/dev/urandom" nil nil 21)
>    (buffer-string))

Thanks for reporting that. I installed the attached patch.
[0001-insert-file-contents-small-gap-bug.patch (text/x-patch, attachment)]

This bug report was last modified 2 days ago.

Previous Next


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