Subject: 31.0.50; Setting display-line-numbers-type to 'relative crashes Emacs when opening certain files
From: Yiyu Zhou <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Date: Mon, 17 Feb 2025 00:15:31 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

This bug is reproducible with two lines in the init.el file:

(global-display-line-numbers-mode 1)
(setopt display-line-numbers-type 'relative)

I discovered this when calling `push-button' in the help-mode buffer
trying to view a function definition in its source. I suspect the
overflow happens when loading a large file into the buffer, since I
could open certain files without crashing Emacs.

Here are the details of the backtrace:

*** buffer overflow detected ***: terminated
Fatal error 6: Aborted
Backtrace:
/run/current-system/sw/bin/emacs() [0x588c88]
/run/current-system/sw/bin/emacs() [0x424402]
/run/current-system/sw/bin/emacs() [0x42492c]
/run/current-system/sw/bin/emacs() [0x424933]
/run/current-system/sw/bin/emacs() [0x586b49]
/nix/store/81mi7m3k3wsiz9rrrg636sx21psj20hc-glibc-2.40-66/lib/libc.so.6(+0x40a70) 
[0x7fa8ba640a70]
/nix/store/81mi7m3k3wsiz9rrrg636sx21psj20hc-glibc-2.40-66/lib/libc.so.6(+0x9876c) 
[0x7fa8ba69876c]
/nix/store/81mi7m3k3wsiz9rrrg636sx21psj20hc-glibc-2.40-66/lib/libc.so.6(gsignal+0x16) 
[0x7fa8ba6409c6]
/nix/store/81mi7m3k3wsiz9rrrg636sx21psj20hc-glibc-2.40-66/lib/libc.so.6(abort+0xd7) 
[0x7fa8ba628938]
/nix/store/81mi7m3k3wsiz9rrrg636sx21psj20hc-glibc-2.40-66/lib/libc.so.6(+0x2978b) 
[0x7fa8ba62978b]
/nix/store/81mi7m3k3wsiz9rrrg636sx21psj20hc-glibc-2.40-66/lib/libc.so.6(+0x126e09) 
[0x7fa8ba726e09]
/nix/store/81mi7m3k3wsiz9rrrg636sx21psj20hc-glibc-2.40-66/lib/libc.so.6(+0x126714) 
[0x7fa8ba726714]
/nix/store/81mi7m3k3wsiz9rrrg636sx21psj20hc-glibc-2.40-66/lib/libc.so.6(__strcat_chk+0x3a) 
[0x7fa8ba7282ba]
/run/current-system/sw/bin/emacs() [0x46c1e5]
/run/current-system/sw/bin/emacs() [0x47a1d7]
/run/current-system/sw/bin/emacs() [0x47c77c]
/run/current-system/sw/bin/emacs() [0x49b9d1]
/run/current-system/sw/bin/emacs() [0x49e06b]
/run/current-system/sw/bin/emacs() [0x5f914c]
/run/current-system/sw/bin/emacs() [0x44c4b9]
/run/current-system/sw/bin/emacs() [0x44c4e5]
/run/current-system/sw/bin/emacs() [0x481eb0]
/run/current-system/sw/bin/emacs() [0x574d68]
/run/current-system/sw/bin/emacs() [0x578854]
/run/current-system/sw/bin/emacs() [0x57a6c2]
/run/current-system/sw/bin/emacs() [0x5f90b7]
/run/current-system/sw/bin/emacs() [0x5638ee]
/run/current-system/sw/bin/emacs() [0x5f8fa3]
/run/current-system/sw/bin/emacs() [0x563886]
/run/current-system/sw/bin/emacs() [0x568b28]
/run/current-system/sw/bin/emacs() [0x568ecf]
/run/current-system/sw/bin/emacs() [0x42d1de]
/nix/store/81mi7m3k3wsiz9rrrg636sx21psj20hc-glibc-2.40-66/lib/libc.so.6(+0x2a1fc) 
[0x7fa8ba62a1fc]
/nix/store/81mi7m3k3wsiz9rrrg636sx21psj20hc-glibc-2.40-66/lib/libc.so.6(__libc_start_main+0x89) 
[0x7fa8ba62a2b9]
/run/current-system/sw/bin/emacs() [0x42d7e5]
Aborted (core dumped)

In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
version 1.18.2, Xaw3d scroll bars)
Repository revision: 35d4316101752fc45bfd2301d891fb7b64060500
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12401005
System Description: NixOS 25.05 (Warbler)

Configured using:
'configure
--prefix=/nix/store/5ar1qipbd7cgz3ggqxlrvhlymziddavj-emacs-git-20250216.0
--disable-build-details --with-modules --with-x-toolkit=lucid
--with-cairo --without-xft --with-compress-install
--with-toolkit-scroll-bars --with-native-compilation
--without-imagemagick --with-mailutils --without-small-ja-dic
--with-tree-sitter --with-xinput2 --without-xwidgets --with-dbus
--with-selinux'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XAW3D XDBE XIM XINPUT2 XPM
LUCID ZLIB

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

Major mode: Fundamental

Minor modes in effect:
global-display-line-numbers-mode: t
tooltip-mode: t
global-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
blink-cursor-mode: t
minibuffer-regexp-mode: t
buffer-read-only: 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:
/run/current-system/sw/share/emacs/site-lisp/site-start hides 
/nix/store/5ar1qipbd7cgz3ggqxlrvhlymziddavj-emacs-git-20250216.0/share/emacs/site-lisp/site-start

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util time-date mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils compile text-property-search
comint subr-x ansi-osc ansi-color ring comp-run bytecomp byte-compile
comp-common rx cus-edit pp cus-load icons wid-edit cl-loaddefs cl-lib
display-line-numbers 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 threads dbusbind inotify
dynamic-setting system-font-setting font-render-setting cairo x-toolkit
xinput2 x multi-tty move-toolbar make-network-process tty-child-frames
native-compile emacs)

Memory information:
((conses 16 91860 20792) (symbols 48 8493 0) (strings 32 22134 1240)
(string-bytes 1 758171) (vectors 16 12148)
(vector-slots 8 167468 10150) (floats 8 31 1) (intervals 56 435 0)
(buffers 992 12))