From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.bugs Subject: bug#31594: Code causes guild compile to hang Date: Tue, 05 Jun 2018 18:01:34 -0400 Message-ID: <87efhk3nb5.fsf@netris.org> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1528236072 30156 195.159.176.226 (5 Jun 2018 22:01:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 5 Jun 2018 22:01:12 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: 31594@debbugs.gnu.org To: Tommi =?UTF-8?Q?H=C3=B6yn=C3=A4l=C3=A4nmaa?= Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Wed Jun 06 00:01:08 2018 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fQK0q-0007jQ-4n for guile-bugs@m.gmane.org; Wed, 06 Jun 2018 00:01:08 +0200 Original-Received: from localhost ([::1]:49314 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQK2v-0000Ik-BK for guile-bugs@m.gmane.org; Tue, 05 Jun 2018 18:03:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQK2l-0000Ic-0f for bug-guile@gnu.org; Tue, 05 Jun 2018 18:03:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQK2h-0005kl-1d for bug-guile@gnu.org; Tue, 05 Jun 2018 18:03:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55886) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fQK2g-0005kX-TW for bug-guile@gnu.org; Tue, 05 Jun 2018 18:03:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fQK2g-0007NZ-Ga for bug-guile@gnu.org; Tue, 05 Jun 2018 18:03:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 05 Jun 2018 22:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31594 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 31594-submit@debbugs.gnu.org id=B31594.152823618028357 (code B ref 31594); Tue, 05 Jun 2018 22:03:02 +0000 Original-Received: (at 31594) by debbugs.gnu.org; 5 Jun 2018 22:03:00 +0000 Original-Received: from localhost ([127.0.0.1]:35550 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fQK2d-0007NI-1x for submit@debbugs.gnu.org; Tue, 05 Jun 2018 18:03:00 -0400 Original-Received: from world.peace.net ([64.112.178.59]:50942) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fQK2b-0007N5-Mx for 31594@debbugs.gnu.org; Tue, 05 Jun 2018 18:02:58 -0400 Original-Received: from mhw by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fQK2U-0006Su-U2; Tue, 05 Jun 2018 18:02:51 -0400 In-Reply-To: ("Tommi \=\?utf-8\?B\?SMO2eW7DpGzDpG5tYWEiJ3M\=\?\= message of "Fri, 25 May 2018 18:32:24 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.org gmane.lisp.guile.bugs:9055 Archived-At: Hi, Tommi H=C3=B6yn=C3=A4l=C3=A4nmaa writes: > The following code causes command "guild compile" to hang: > ---cut here--- > (define (select-nearest-methods binder > index v-fixed-args v-rest-arg vb-included) > (dwl4 "select-nearest-methods") > (assert (is-binder? binder)) > (let ((n (vector-length vb-included))) > (do ((i 0 (+ i 1))) ((>=3D i n)) > (if (vector-ref vb-included i) > (let ((t1 (get-item-at-index > (vector-ref v-fixed-args i) > (vector-ref v-rest-arg i) > index))) > (do ((j 0 (+ j 1))) ((>=3D j n)) > (if (and (not (=3D i j)) > (vector-ref vb-included j)) > (let ((t2 (get-item-at-index > (vector-ref v-fixed-args j) > (vector-ref v-rest-arg j) > index))) > (if (is-t-subtype? binder t1 t2) > ;; t2 is excluded > (vector-set! vb-included j #f)))))))))) > ---cut here--- I can reproduce this with Guile-2.2.3 on my system running GuixSD. Simply pasting the above code into a pristine Guile REPL causes it to hang. I'm able to compile it to cps, but compiling it to bytecode gets stuck in what appears to be an infinite loop in 'specialize-operations' in (language cps specialize-numbers). The backtrace printer also gets stuck in a loop while trying to print one of the stack frames in (language cps specialize-numbers). See below for a transcript. Thanks for the report. To be continued... Mark --8<---------------cut here---------------start------------->8--- GNU Guile 2.2.3 Copyright (C) 1995-2017 Free Software Foundation, Inc. Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'. This program is free software, and you are welcome to redistribute it under certain conditions; type `,show c' for details. Enter `,help' for help. scheme@(guile-user)> (define (select-nearest-methods binder index v-fixed-args v-rest-arg vb-included) (dwl4 "select-nearest-methods") (assert (is-binder? binder)) (let ((n (vector-length vb-included))) (do ((i 0 (+ i 1))) ((>=3D i n)) (if (vector-ref vb-included i) (let ((t1 (get-item-at-index (vector-ref v-fixed-args i) (vector-ref v-rest-arg i) index))) (do ((j 0 (+ j 1))) ((>=3D j n)) (if (and (not (=3D i j)) (vector-ref vb-included j)) (let ((t2 (get-item-at-index (vector-ref v-fixed-args j) (vector-ref v-rest-arg j) index))) (if (is-t-subtype? binder t1 t2) ;; t2 is excluded (vector-set! vb-included j #f)))))))))) ;;; :6:2: warning: possibly unbound variable `dwl4' ;;; :7:2: warning: possibly unbound variable `assert' ;;; :7:10: warning: possibly unbound variable `is-binder?' ;;; :11:16: warning: possibly unbound variable `get-item-at-index' ;;; :18:20: warning: possibly unbound variable `get-item-at-index' ;;; :22:16: warning: possibly unbound variable `is-t-subtype?' While compiling expression: User interrupt scheme@(guile-user)> ,use (system base compile) scheme@(guile-user)> (define code '(define (select-nearest-methods binder index v-fixed-args v-rest-arg vb-included) (dwl4 "select-nearest-methods") (assert (is-binder? binder)) (let ((n (vector-length vb-included))) (do ((i 0 (+ i 1))) ((>=3D i n)) (if (vector-ref vb-included i) (let ((t1 (get-item-at-index (vector-ref v-fixed-args i) (vector-ref v-rest-arg i) index))) (do ((j 0 (+ j 1))) ((>=3D j n)) (if (and (not (=3D i j)) (vector-ref vb-included j)) (let ((t2 (get-item-at-index (vector-ref v-fixed-args j) (vector-ref v-rest-arg j) index))) (if (is-t-subtype? binder t1 t2) ;; t2 is excluded (vector-set! vb-included j #f))))))))))) scheme@(guile-user)> ,pp code $2 =3D (define (select-nearest-methods binder index v-fixed-args v-rest-arg vb-included) (dwl4 "select-nearest-methods") (assert (is-binder? binder)) (let ((n (vector-length vb-included))) (do ((i 0 (+ i 1))) ((>=3D i n)) (if (vector-ref vb-included i) (let ((t1 (get-item-at-index (vector-ref v-fixed-args i) (vector-ref v-rest-arg i) index))) (do ((j 0 (+ j 1))) ((>=3D j n)) (if (and (not (=3D i j)) (vector-ref vb-included j)) (let ((t2 (get-item-at-index (vector-ref v-fixed-args j) (vector-ref v-rest-arg j) index))) (if (is-t-subtype? binder t1 t2) (vector-set! vb-included j #f)))))))))) scheme@(guile-user)> (define v (compile code #:from 'scheme #:to 'cps)) scheme@(guile-user)> v $3 =3D # scheme@(guile-user)> (define intmap->alist (@@ (language cps intmap) intmap= ->alist)) scheme@(guile-user)> ,pp (intmap->alist v) $4 =3D ((0 . #) (1 . #) (2 . #) (3 . #) (4 . #) (5 . #) (6 . #) (7 . #) (8 . #) (9 . #) (10 . #) (11 . #) (12 . #) (13 . #) (14 . #) (15 . #) (16 . #) (17 . #) (18 . #) (19 . #) (20 . #) (21 . #) (22 . #) (23 . #) (24 . #) (25 . #) (26 . #u64 11)))>) (27 . #) (28 . #) (29 . #) (30 . #) (31 . #) (32 . #) (33 . #) (34 . #) (35 . #) (36 . #) (37 . #) (38 . #) (39 . #) (40 . #) (41 . #) (42 . #u64 11)))>) (43 . #) (44 . #u64 11)))>) (45 . #) (46 . #) (47 . #) (48 . #) (49 . #) (50 . #) (51 . #) (52 . #) (53 . #) (54 . #) (55 . #) (56 . #) (57 . #) (58 . #u64 11)))>) (59 . #) (60 . #) (61 . #=3D 11 6)))= )>) (62 . #) (63 . #) (64 . #) (65 . #) (66 . #) (67 . #) (68 . #) (69 . #) (70 . #u64 8)))>) (71 . #) (72 . #u64 8)))>) (73 . #) (74 . #) (75 . #) (76 . #) (77 . #) (78 . #) (79 . #) (80 . #) (81 . #) (82 . #) (83 . #) (84 . #) (85 . #u64 8)))>) (86 . #=3D 8 6))))>) (87 . #) (88 . #) (89 . #) (90 . #) (91 . #scm 73)))>) (92 . #) (93 . #) (94 . #) (95 . #) (96 . #) (97 . #) (98 . #) (99 . #) (100 . #) (101 . #) (102 . #) (103 . #) (104 . #) (105 . #) (106 . #) (107 . #) (108 . #) (109 . #) (110 . #) (111 . #) (112 . #) (113 . #) (114 . #) (115 . #) (116 . #) (117 . #) (118 . #) (119 . #) (120 . #) (121 . #) (122 . #)) scheme@(guile-user)> (define vb (compile code #:from 'scheme #:to 'bytecode= )) ERROR: In procedure scm-error: User interrupt Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. scheme@(guile-user) [1]> ,bt In current input: 82:11 13 (_) In system/base/compile.scm: 255:6 12 (compile _ #:from _ #:to _ #:env _ #:opts _) 183:32 11 (compile-fold _ _ _ ()) In language/cps/compile-bytecode.scm: 609:12 10 (compile-bytecode _ # ()) 603:12 9 (lower-cps _ _) In language/cps/optimize.scm: 106:0 8 (optimize-first-order-cps _ _) In language/cps/specialize-numbers.scm: 724:23 7 (specialize-numbers _) 438:10 6 (specialize-operations _) In language/cps/intmap.scm: 521:5 5 (visit-branch #(#(# # # =E2=80=A6) =E2=80=A6) =E2=80=A6) 521:5 4 (visit-branch #(# # # #= =E2=80=A6) =E2=80=A6) In language/cps/specialize-numbers.scm: --8<---------------cut here---------------end--------------->8---