Subject: 30.0.93; Infinite loop in comp--native-compile

From: Hugh Daschbach <[email-masked]>
Date: Thu, 26 Dec 2024 16:15:25 -0800

Emacs hangs when attempting to compile tests from obsolete ELPA package
seq.

To reproduce:

```
 curl -o /tmp/seq-tests.el https://git.savannah.gnu.org/cgit/emacs/elpa.git/plain/tests/seq-tests.el?h=externals/seq
$ emacs -Q --eval "(progn (setq debug-on-quit t) (require 'comp) (comp--native-compile \"/tmp/seq-tests.el\" nil))"
```

Press C-g shortly after the Emacs frame opens.  This produces the
following backtrace:

```
Debugger entered--Lisp error: (quit)
  #f(compiled-function (x) #<bytecode -0x145e3142cf39a7e4>)(1)
  cl--nsublis-rec((1 . #1))
  cl--nsublis-rec((#s(comp-mvar :typeset (t) :valset nil :range nil :neg nil :id 34397705172435 :slot 0) (1 . #3)))
  cl--nsublis-rec(((#s(comp-mvar :typeset (t) :valset nil :range nil :neg nil :id 34397705172435 :slot 0) (1 . #4))))
  cl-nsublis(((nil . #s(comp-mvar :typeset (t) :valset nil :range nil :neg nil :id 34397705043564 :slot 1))) (#s(comp-mvar :typeset (t) :valset nil :range nil :neg nil :id 34397705172435 :slot 0) (1 . #4)) :if #f(compiled-function (x) #<bytecode -0x145e3142cf39a7e4>))
  cl-nsubst-if(#s(comp-mvar :typeset (t) :valset nil :range nil :neg nil :id 34397705043564 :slot 1) #f(compiled-function (x) #<bytecode -0x145e3142cf39a7e4>) (#s(comp-mvar :typeset (t) :valset nil :range nil :neg nil :id 34397705172435 :slot 0) (1 . #5)))
  comp--ssa-rename-insn((setimm #s(comp-mvar :typeset (t) :valset nil :range nil :neg nil :id 34397705172435 :slot 0) (1 . #4)) #s(comp-vec :data #<hash-table eql 5/6 0x1f48d6ffbc9c ...> :beg 0 :end 5))
  #f(compiled-function (bb in-frame) #<bytecode -0x950d6b51c773586>)(#s(comp-block-lap :name bb_0 :insns ((setimm #s(comp-mvar :typeset (t) :valset nil :range nil :neg nil :id 34397705172435 :slot 0) (1 . #6)) (call specbind #s(comp-mvar :typeset nil :valset (l1) :range nil :neg nil :id nil :slot nil) #s(comp-mvar :typeset (t) :valset nil :range nil :neg nil :id nil :slot 0)) (setimm #s(comp-mvar :typeset (t) :valset nil :range nil :neg nil :id nil :slot 0) equal) (call specbind #s(comp-mvar :typeset nil :valset (fn-1716) :range nil :neg nil :id nil :slot nil) #s(comp-mvar :typeset (t) :valset nil :range nil :neg nil :id nil :slot 0)) (setimm #s(comp-mvar :typeset (t) :valset nil :range nil :neg nil :id nil :slot 0) (error)) (push-handler condition-case #s(comp-mvar :typeset (t) :valset nil :range nil :neg nil :id nil :slot 0) bb_3 bb_1)) :closed t :in-edges (#s(comp-edge :src #s(comp-block-lap :name entry :insns ((comment "Lisp function: nil") (jump bb_0)) :closed nil :in-edges nil :out-edges (#3) :idom #4 :df #<hash-table eql 0/0 0x1f48d6d5dc56 ...> :post-num 7 :final-frame #s(comp-vec :data #<hash-table eql 5/6 0x1f48d6f5e86a ...> :beg 0 :end 5) :sp -1 :addr nil :non-ret-insn nil :no-ret nil) :dst #1 :number 0)) :out-edges (#s(comp-edge :src #1 :dst #s(comp-block-lap :name bb_1 :insns ((setimm #s(comp-mvar :typeset ... :valset nil :range nil :neg nil :id nil :slot 0) seq-mapn) (setimm #s(comp-mvar :typeset ... :valset nil :range nil :neg nil :id nil :slot 1) +) (setimm #s(comp-mvar :typeset ... :valset nil :range nil :neg nil :id nil :slot 2) (3 4 5 7)) (set #s(comp-mvar :typeset ... :valset nil :range nil :neg nil :id nil :slot 3) (call symbol-value ...)) (set #s(comp-mvar :typeset ... :valset nil :range nil :neg nil :id nil :slot 0) (callref funcall ... ... ... ...)) (setimm #s(comp-mvar :typeset ... :valset nil :range nil :neg nil :id nil :slot 1) (4 5 6 8)) (set #s(comp-mvar :typeset ... :valset nil :range nil :neg nil :id nil :slot 1) (call cons ... ...)) (set #s(comp-mvar :typeset ... :valset nil :range nil :neg nil :id nil :slot 0) (call cons ... ...)) (pop-handler) (jump bb_4)) :closed t :in-edges (#3) :out-edges (#s(comp-edge :src #4 :dst #s(comp-block-lap :name bb_4 :insns ... :closed t :in-edges ... :out-edges ... :idom #1 :df #<hash-table eql 0/0 0x1f48d6db0e9b ...> :post-num 2 :final-frame nil :sp 0 :addr 25 :non-ret-insn nil :no-ret nil) :number 8)) :idom #1 :df #<hash-table eql 1/6 0x1f48d6df564a ...> :post-num 3 :final-frame nil :sp -1 :addr 6 :non-ret-insn nil :no-ret nil) :number 2) #s(comp-edge :src #1 :dst #s(comp-block-lap :name bb_3 :insns ((fetch-handler #s(comp-mvar :typeset ... :valset nil :range nil :neg nil :id nil :slot 0)) (jump bb_2)) :closed t :in-edges (#4) :out-edges (#s(comp-edge :src #5 :dst #s(comp-block-lap :name bb_2 :insns ... :closed nil :in-edges ... :out-edges ... :idom #5 :df #<hash-table eql 1/6 0x1f48d6ddb42f ...> :post-num 4 :final-frame nil :sp 0 :addr 15 :non-ret-insn nil :no-ret nil) :number 3)) :idom #1 :df #<hash-table eql 1/6 0x1f48d6dd6fb2 ...> :post-num 5 :final-frame nil :sp -1 :addr nil :non-ret-insn nil :no-ret nil) :number 1)) :idom #s(comp-block-lap :name entry :insns ((comment "Lisp function: nil") (jump bb_0)) :closed nil :in-edges nil :out-edges (#s(comp-edge :src #2 :dst #1 :number 0)) :idom #2 :df #<hash-table eql 0/0 0x1f48d6d5dc56 ...> :post-num 7 :final-frame #s(comp-vec :data #<hash-table eql 5/6 0x1f48d6f5e86a ...> :beg 0 :end 5) :sp -1 :addr nil :non-ret-insn nil :no-ret nil) :df #<hash-table eql 0/0 0x1f48d6d5d965 ...> :post-num 6 :final-frame nil :sp -1 :addr 0 :non-ret-insn nil :no-ret nil) #s(comp-vec :data #<hash-table eql 5/6 0x1f48d6ffbc9c ...> :beg 0 :end 5))
  #f(compiled-function (bb in-frame) #<bytecode -0x950d6b51c773586>)(#s(comp-block-lap :name entry :insns ((comment "Lisp function: nil") (jump bb_0)) :closed nil :in-edges nil :out-edges (#s(comp-edge :src #1 :dst #s(comp-block-lap :name bb_0 :insns ((setimm #s(comp-mvar :typeset ... :valset nil :range nil :neg nil :id 34397705172435 :slot 0) (1 . #9)) (call specbind #s(comp-mvar :typeset nil :valset ... :range nil :neg nil :id nil :slot nil) #s(comp-mvar :typeset ... :valset nil :range nil :neg nil :id nil :slot 0)) (setimm #s(comp-mvar :typeset ... :valset nil :range nil :neg nil :id nil :slot 0) equal) (call specbind #s(comp-mvar :typeset nil :valset ... :range nil :neg nil :id nil :slot nil) #s(comp-mvar :typeset ... :valset nil :range nil :neg nil :id nil :slot 0)) (setimm #s(comp-mvar :typeset ... :valset nil :range nil :neg nil :id nil :slot 0) (error)) (push-handler condition-case #s(comp-mvar :typeset ... :valset nil :range nil :neg nil :id nil :slot 0) bb_3 bb_1)) :closed t :in-edges (#3) :out-edges (#s(comp-edge :src #4 :dst #s(comp-block-lap :name bb_1 :insns ... :closed t :in-edges ... :out-edges ... :idom #4 :df #<hash-table eql 1/6 0x1f48d6df564a ...> :post-num 3 :final-frame nil :sp -1 :addr 6 :non-ret-insn nil :no-ret nil) :number 2) #s(comp-edge :src #4 :dst #s(comp-block-lap :name bb_3 :insns ... :closed t :in-edges ... :out-edges ... :idom #4 :df #<hash-table eql 1/6 0x1f48d6dd6fb2 ...> :post-num 5 :final-frame nil :sp -1 :addr nil :non-ret-insn nil :no-ret nil) :number 1)) :idom #1 :df #<hash-table eql 0/0 0x1f48d6d5d965 ...> :post-num 6 :final-frame nil :sp -1 :addr 0 :non-ret-insn nil :no-ret nil) :number 0)) :idom #1 :df #<hash-table eql 0/0 0x1f48d6d5dc56 ...> :post-num 7 :final-frame #s(comp-vec :data #<hash-table eql 5/6 0x1f48d6f5e86a ...> :beg 0 :end 5) :sp -1 :addr nil :non-ret-insn nil :no-ret nil) #s(comp-vec :data #<hash-table eql 5/6 0x1f48d6f5e86a ...> :beg 0 :end 5))
  comp--ssa-rename()
  #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_100>("F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_399" #s(comp-func-d :name nil :c-name "F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_399" :byte-func #f(compiled-function () #<bytecode 0x1d75f3728f817ae2>) :doc nil :int-spec nil :command-modes nil :lap ((byte-constant (1 . #6) . 6) (byte-varbind l1 . 0) (byte-constant equal . 7) (byte-varbind fn-1716 . 1) (byte-constant (error) . 8) (byte-pushconditioncase TAG 19 . 1) (byte-constant seq-mapn . 9) (byte-constant + . 10) (byte-constant (3 4 5 7) . 11) (byte-varref l1 . 0) (byte-call . 3) (byte-constant (4 5 6 8) . 12) (byte-list2 . 0) (byte-pophandler) (byte-goto TAG 28 . 1) (TAG 19 . 1) (byte-varbind err . 2) (byte-constant signal . 13) (byte-varset fn-1716 . 1) (byte-varref err . 2) (byte-car . 0) (byte-varref err . 2) (byte-cdr . 0) (byte-unbind . 1) (byte-list2 . 0) (TAG 28 . 1) (byte-varbind args-1717 . 3) (byte-constant ert-form-evaluation-aborted-1719 . 14) (byte-varbind value-1718 . 4) (byte-constant nil . 15) (byte-varbind form-description-1720 . 5) (byte-constant #f(compiled-function () #<bytecode 0x4331903cd0037d8>) . 16) (byte-unwind-protect . 0) (byte-constant apply . 17) (byte-varref fn-1716 . 1) (byte-varref args-1717 . 3) (byte-call . 2) (byte-dup . 0) (byte-varset value-1718 . 4) (byte-unbind . 1) (byte-goto-if-not-nil TAG 49 . 0) (byte-constant ert-fail . 18) (byte-varref form-description-1720 . 5) (byte-call . 1) (byte-discard) (TAG 49 . 0) (byte-unbind . 1) (byte-varref value-1718 . 4) (byte-unbind . 4) (byte-constant nil . 15) ...) :ssa-status nil :frame-size 5 :vframe-size 0 :blocks #<hash-table eq 8/24 0x1f48d6ca4ed6 ...> :lap-block #<hash-table equal 0/0 0x1f48d6ca4ec0 ...> :edges-h #<hash-table eql 9/24 0x1f48d6ca4f55 ...> :block-cnt-gen #f(compiled-function () #<bytecode 0x41f1ebb0af513a>) :edge-cnt-gen #f(compiled-function () #<bytecode 0x41f1ebb0af51e2>) :has-non-local t :speed 2 :safety 1 :pure nil :declared-type nil :type #s(comp-mvar :typeset nil :valset (nil) :range nil :neg nil :id nil :slot nil) :lambda-list nil))
  comp--ssa()
  comp--fwprop(nil)
  comp--native-compile("/tmp/seq-tests.el" nil)
  (progn (setq debug-on-quit t) (require 'comp) (comp--native-compile "/tmp/seq-tests.el" nil))
  eval((progn (setq debug-on-quit t) (require 'comp) (comp--native-compile "/tmp/seq-tests.el" nil)) t)
  command-line-1(("--eval" "(progn (setq debug-on-quit t) (require 'comp) (comp--native-compile \"/tmp/seq-tests.el\" nil))"))
  command-line()
  normal-top-level()
```

Admittedly, trying to compile an obsolete ELPA package is not a good
idea.  In fact, it was a configuration bug.  But it might be interesting
to see why the compiler hangs.

Thanks,
Hugh

--

In GNU Emacs 30.0.93 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.18.2, Xaw3d scroll bars) of 2024-12-24 built on klaatu
Repository revision: 8064b2a67988e815c52e289fe2a235ce1008776f
Repository branch: emacs-30
Windowing system distributor 'The X.Org Foundation', version 11.0.12401004
System Description: Arch Linux

Configured using:
 'configure --with-x-toolkit=lucid --with-native-compilation
 --prefix=/home/hugh/.local'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBSYSTEMD LIBXML2 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 $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  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 comp-run emacsbug message mailcap yank-media puny
dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg
rfc6068 epg-config gnus-util mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils thingatpt help-fns radix-tree
cl-print time-date pcase cl-macs ert map byte-opt pp ewoc debug
backtrace find-func compile text-property-search comint ansi-osc
ansi-color ring comp cl-seq comp-cstr cl-extra help-mode comp-common
warnings icons subr-x rx gv cl-loaddefs cl-lib bytecomp byte-compile 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 lcms2 dynamic-setting system-font-setting
font-render-setting cairo x-toolkit xinput2 x multi-tty move-toolbar
make-network-process native-compile emacs)

Memory information:
nil