From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#58601: 29.0.50; Infinite loop in byte-compile--first-symbol-with-pos Date: Tue, 18 Oct 2022 02:24:02 +0300 Message-ID: <8735bm6nl9.fsf@tcd.ie> Reply-To: "Basil L. Contovounesios" Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36528"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Alan Mackenzie , Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= , Stefan Monnier To: 58601@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 18 01:25:35 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1okZUF-0009IY-5o for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 18 Oct 2022 01:25:35 +0200 Original-Received: from localhost ([::1]:54304 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okZUD-0000bE-CB for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 17 Oct 2022 19:25:33 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33104) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okZTl-0000aq-2m for bug-gnu-emacs@gnu.org; Mon, 17 Oct 2022 19:25:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51355) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1okZTk-0005Lf-KN for bug-gnu-emacs@gnu.org; Mon, 17 Oct 2022 19:25:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1okZTi-0000Bc-4Q; Mon, 17 Oct 2022 19:25:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: acm@muc.de, mattiase@acm.org, monnier@iro.umontreal.ca, bug-gnu-emacs@gnu.org Resent-Date: Mon, 17 Oct 2022 23:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 58601 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: Alan Mackenzie , Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= , Stefan Monnier Original-Received: via spool by submit@debbugs.gnu.org id=B.1666049068657 (code B ref -1); Mon, 17 Oct 2022 23:25:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 17 Oct 2022 23:24:28 +0000 Original-Received: from localhost ([127.0.0.1]:50431 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1okZT9-0000AW-4t for submit@debbugs.gnu.org; Mon, 17 Oct 2022 19:24:27 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:54956) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1okZT7-0000AN-C5 for submit@debbugs.gnu.org; Mon, 17 Oct 2022 19:24:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45198) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okZT6-0000WD-Ur for bug-gnu-emacs@gnu.org; Mon, 17 Oct 2022 19:24:25 -0400 Original-Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]:39520) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1okZT0-0005Hx-5f for bug-gnu-emacs@gnu.org; Mon, 17 Oct 2022 19:24:24 -0400 Original-Received: by mail-ej1-x631.google.com with SMTP id b2so28430155eja.6 for ; Mon, 17 Oct 2022 16:24:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd.ie; s=google21; h=mime-version:user-agent:message-id:date:subject:to:from:from:to:cc :subject:date:message-id:reply-to; bh=dFUm0MQWctEClWc9VZqOT3iTdWxnElHWLppamAzRNkA=; b=Jn14eB30smQHJGfe42107zQYRBU0c0jg17Ga5SBx9cRUeso/oJqUSuV3iiEi0O894d Qj/4ZJ7X/b4KC2NG1vI0HpNQJ3pWxU2xXBWatcd5CPGPL1t44MS2fAy4nW0yua7nb5p8 NOPvQ68fo8PPl+Vl3aYMvBZRJIoAac8SWNq5a0oj7nQdyek10KNlY4BS7Qtr8e6BssMZ Sj9/DjLQeI00Xy4fOKBXkegcqTLwM9dAwMlN7Q6reLwcjAJWfQmwASW9l4OYuJ7vwJsB bEuadre3Eaf/3W6kVIyERRgsAiDIgXWTF6MSjnjMSBmFTAdCGn56V7VQa9Lyz/I1qbXa +V5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:date:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dFUm0MQWctEClWc9VZqOT3iTdWxnElHWLppamAzRNkA=; b=gdRrokGiV68RVQYw6lHsGwmwaNUyxJHuadCYAMgCPWj82Nr6fXNPw1SYpCSiPx6H0l riPvM4NQdBPdeLoE3A4rCzhLBimHReOYnaIN9xHQO6TCuG79OTXP41BUyRXUO9urhMam EEjZk0Rf9Zeqge6+mPuaYrCOm5/0sEOsvoNwUJo220zfT1pUFqggokX1b9V1xzFnJ9Mm wHwvlFSXOYR1HPRcICGx4MFyj807zZAwUSNofCSW8wH79IgYJ8vkUdMCuU9JiOtZCS2L C+ccHee3l1sGQki6gjfYP5IKBWn7HfPs+Dn3nbnxz60nJuvAiPi7y5rObUwFip2rVKFR Efmw== X-Gm-Message-State: ACrzQf03X5ambdgVqkHgeMLNrYWvcpoLICRcCGzS6qVItAdmA5XyO7Gb n5203AAAtwT3CIwuUnZkQ8HkEtG4BY1nQw== X-Google-Smtp-Source: AMsMyM59YnYY6LnIh3QI9kIfcg2GWOjnwgxUgyEZv2l4FtNxEBTJkUg+BgWKtv414iizKsVrBYu+qQ== X-Received: by 2002:a17:906:5dcc:b0:78d:fb98:6f85 with SMTP id p12-20020a1709065dcc00b0078dfb986f85mr89887ejv.123.1666049053821; Mon, 17 Oct 2022 16:24:13 -0700 (PDT) Original-Received: from localhost ([2a02:587:321f:7e8a:d9:365a:ced1:b3d1]) by smtp.gmail.com with ESMTPSA id k13-20020a17090627cd00b0077826b92d99sm6747091ejc.12.2022.10.17.16.24.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 16:24:13 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::631; envelope-from=contovob@tcd.ie; helo=mail-ej1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:245761 Archived-At: --=-=-= Content-Type: text/plain Given this sample input file: --=-=-= Content-Type: application/emacs-lisp Content-Disposition: inline; filename=my.el Content-Transfer-Encoding: quoted-printable ;;; my.el -*- lexical-binding: t -*- (require 'ert) (eval-and-compile (defun my-cycle () (declare (pure t)) (let ((list (list t))) (nconc list list))) (defun my-identity (arg) (declare (compiler-macro (lambda (_form) (macroexp-warn-and-return "Oh dear" arg)))) arg)) (ert-deftest my-test () (should (my-identity (my-cycle)))) ;;; my.el ends here --=-=-= Content-Type: text/plain Byte-compiling it as follows hangs indefinitely: emacs -Q -batch -f batch-byte-compile my.el While it's hanging, might as well poke it: pkill -f 'batch-byte-compile my\.el' -SIGUSR2 To which it yields the following backtrace: --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=backtrace.txt Content-Transfer-Encoding: quoted-printable Debugger entered--Lisp error: (quit) byte-compile--first-symbol-with-pos((t . #1)) byte-compile--first-symbol-with-pos('(t . #2)) byte-compile--first-symbol-with-pos((progn (macroexp--funcall-if-compiled= #f(compiled-function () #)) '(t . #5))) byte-compile--first-symbol-with-pos(((my-cycle) (macroexp--funcall-if-com= piled #f(compiled-function () #)) (progn (macro= exp--funcall-if-compiled #f(compiled-function () #)) '(t . #8)) (setcar value-0 (progn (macroexp--funcall-if-compiled #f(c= ompiled-function () #)) '(t . #12))) (unwind-pr= otect (setcar value-0 (progn (macroexp--funcall-if-compiled #f(compiled-fun= ction () #)) '(t . #15))) :fun-body (internal-m= ake-closure nil (form-description-1 value-0) nil (setcar (internal-get-clos= ed-var 0) (list '(should ...) :form '(progn ... ...) :value (car-safe (inte= rnal-get-closed-var 1)))) (ert--signal-should-execution (car-safe (internal= -get-closed-var 0))))) (let ((form-description-1 (list nil))) (unwind-prote= ct (setcar value-0 (progn (macroexp--funcall-if-compiled #f(compiled-functi= on () #)) '(t . #19))) :fun-body (internal-make= -closure nil (form-description-1 value-0) nil (setcar (internal-get-closed-= var 0) (list '... :form '... :value (car-safe ...))) (ert--signal-should-ex= ecution (car-safe (internal-get-closed-var 0)))))) (let ((value-0 (list (ge= nsym "ert-form-evaluation-aborted-")))) (let ((form-description-1 (list nil= ))) (unwind-protect (setcar value-0 (progn (macroexp--funcall-if-compiled #= f(compiled-function () #)) '...)) :fun-body (in= ternal-make-closure nil (form-description-1 value-0) nil (setcar (internal-= get-closed-var 0) (list ... :form ... :value ...)) (ert--signal-should-exec= ution (car-safe ...))))) (car-safe value-0)) #'(lambda nil (let ((value-0 (= list ...))) (let ((form-description-1 ...)) (if (unwind-protect ... :fun-bo= dy ...) nil (ert-fail ...))) (car-safe value-0))) (record 'ert-test 'my-tes= t nil #'(lambda nil (let ((value-0 ...)) (let (...) (if ... nil ...)) (car-= safe value-0))) nil :passed nil "/tmp/my.el") (ert-set-test 'my-test (recor= d 'ert-test 'my-test nil #'(lambda nil (let (...) (let ... ...) (car-safe v= alue-0))) nil :passed nil "/tmp/my.el")) (ert-deftest my-test nil (should (= my-identity (my-cycle)))))) byte-compile--warning-source-offset() byte-compile-log-warning("Oh dear" t :warning) byte-compile-warn("%s" "Oh dear") apply(byte-compile-warn "%s" "Oh dear") byte-compile-warn-x((my-cycle) "%s" "Oh dear") #f(compiled-function () #)() #f(compiled-function (form) #)((macroexp--fu= ncall-if-compiled #f(compiled-function () #))) byte-compile-form((macroexp--funcall-if-compiled #f(compiled-function () = #)) t) byte-compile-body(((macroexp--funcall-if-compiled #f(compiled-function ()= #)) '(t . #4)) nil) byte-compile-progn((progn (macroexp--funcall-if-compiled #f(compiled-func= tion () #)) '(t . #5))) byte-compile-form((progn (macroexp--funcall-if-compiled #f(compiled-funct= ion () #)) '(t . #5))) byte-compile-two-args((setcar value-0 (progn (macroexp--funcall-if-compil= ed #f(compiled-function () #)) '(t . #8)))) byte-compile-form((setcar value-0 (progn (macroexp--funcall-if-compiled #= f(compiled-function () #)) '(t . #8))) t) byte-compile-unwind-protect((unwind-protect (setcar value-0 (progn (macro= exp--funcall-if-compiled #f(compiled-function () #)) '(t . #10))) :fun-body (internal-make-closure nil (form-description-1= value-0) nil (setcar (internal-get-closed-var 0) (list '(should (my-identi= ty ...)) :form '(progn (macroexp--funcall-if-compiled ...) (my-cycle)) :val= ue (car-safe (internal-get-closed-var 1)))) (ert--signal-should-execution (= car-safe (internal-get-closed-var 0)))))) byte-compile-form((unwind-protect (setcar value-0 (progn (macroexp--funca= ll-if-compiled #f(compiled-function () #)) '(t = . #10))) :fun-body (internal-make-closure nil (form-description-1 value-0) = nil (setcar (internal-get-closed-var 0) (list '(should (my-identity ...)) := form '(progn (macroexp--funcall-if-compiled ...) (my-cycle)) :value (car-sa= fe (internal-get-closed-var 1)))) (ert--signal-should-execution (car-safe (= internal-get-closed-var 0))))) t) ... byte-compile-form((record 'ert-test 'my-test nil #'(lambda nil (let ((val= ue-0 (list ...))) (let ((form-description-1 ...)) (if (unwind-protect ... := fun-body ...) nil (ert-fail ...))) (car-safe value-0))) nil :passed nil "/t= mp/my.el")) mapc(byte-compile-form ('my-test (record 'ert-test 'my-test nil #'(lambda= nil (let ((value-0 ...)) (let (...) (if ... nil ...)) (car-safe value-0)))= nil :passed nil "/tmp/my.el"))) byte-compile-normal-call((ert-set-test 'my-test (record 'ert-test 'my-tes= t nil #'(lambda nil (let ((value-0 ...)) (let (...) (if ... nil ...)) (car-= safe value-0))) nil :passed nil "/tmp/my.el"))) byte-compile-form((ert-set-test 'my-test (record 'ert-test 'my-test nil #= '(lambda nil (let ((value-0 ...)) (let (...) (if ... nil ...)) (car-safe va= lue-0))) nil :passed nil "/tmp/my.el")) t) byte-compile-keep-pending((ert-set-test 'my-test (record 'ert-test 'my-te= st nil #'(lambda nil (let ((value-0 ...)) (let (...) (if ... nil ...)) (car= -safe value-0))) nil ':passed 'nil "/tmp/my.el"))) byte-compile-file-form((ert-set-test 'my-test (record 'ert-test 'my-test = nil #'(lambda nil (let ((value-0 ...)) (let (...) (if ... nil ...)) (car-sa= fe value-0))) nil ':passed 'nil "/tmp/my.el"))) #f(compiled-function (form) #)((ert-set-tes= t 'my-test (record 'ert-test 'my-test nil #'(lambda nil (let ((value-0 ...)= ) (let (form-description-1) (if ... nil ...)) value-0)) nil ':passed 'nil "= /tmp/my.el"))) byte-compile-recurse-toplevel((ert-set-test 'my-test (record 'ert-test 'm= y-test nil #'(lambda nil (let ((value-0 ...)) (let (form-description-1) (if= ... nil ...)) value-0)) nil ':passed 'nil "/tmp/my.el")) #f(compiled-funct= ion (form) #)) #f(compiled-function (subform) #)((ert-set-t= est 'my-test (record 'ert-test 'my-test nil #'(lambda nil (let ((value-0 ..= .)) (let (form-description-1) (if ... nil ...)) value-0)) nil ':passed 'nil= "/tmp/my.el"))) mapcar(#f(compiled-function (subform) #) ((e= rt-set-test 'my-test (record 'ert-test 'my-test nil #'(lambda nil (let (...= ) (let ... ...) value-0)) nil ':passed 'nil "/tmp/my.el")) 'my-test)) byte-compile-recurse-toplevel((ert-deftest my-test nil (should (my-identi= ty (my-cycle)))) #f(compiled-function (form) #)) byte-compile-toplevel-file-form((ert-deftest my-test nil (should (my-iden= tity (my-cycle))))) #f(compiled-function (inbuffer) #)(#) byte-compile-from-buffer(#) byte-compile-file("my.el") batch-byte-compile-file("my.el") batch-byte-compile() command-line-1(("-f" "batch-byte-compile" "my.el")) command-line() normal-top-level() --=-=-= Content-Type: text/plain I.e. the 'pure' compile-time form has a cycle, and the DFS of byte-compile--first-symbol-with-pos gets lost. Paraphrasing Stefan, it's acceptable if the compiler mishandles circular source code, but it should be able to handle circular data. I don't know why, but I can reproduce the hang only when the form is inside ert-deftest+should, and not inside a plain defun. Perhaps byte-compile--first-symbol-with-pos needs to employ something like byte-run--ssp-seen? Or does ERT somehow come into play? Thanks, -- Basil In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars) of 2022-10-18 built on tia Repository revision: c2b79d9148f21c3717f1eaa2d37b837b0922b94c Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101004 System Description: Debian GNU/Linux bookworm/sid Configured using: 'configure 'CFLAGS=-Og -ggdb3' -C --prefix=/home/blc/.local --enable-checking=structs --with-file-notification=yes --with-x-toolkit=lucid --with-x' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11 XAW3D XDBE XIM XINPUT2 XPM LUCID ZLIB Important settings: value of $LANG: en_IE.UTF-8 value of $XMODIFIERS: @im=ibus 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 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 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 rmc iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd 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 make-network-process emacs) Memory information: ((conses 16 36538 7652) (symbols 48 5112 0) (strings 32 13853 1864) (string-bytes 1 382346) (vectors 16 9260) (vector-slots 8 147212 11667) (floats 8 23 25) (intervals 56 242 0) (buffers 1000 10)) --=-=-=--