From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.lisp.guile.bugs Subject: segvs on memoized macro backtraces Date: Tue, 18 Feb 2003 07:55:45 +1000 Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Message-ID: <87adguwp0e.fsf@zip.com.au> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: main.gmane.org 1045518907 21650 80.91.224.249 (17 Feb 2003 21:55:07 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 17 Feb 2003 21:55:07 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18ktE9-0005cz-00 for ; Mon, 17 Feb 2003 22:55:05 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18ktG3-0005yl-00 for guile-bugs@m.gmane.org; Mon, 17 Feb 2003 16:57:03 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18ktFv-0005tb-00 for bug-guile@gnu.org; Mon, 17 Feb 2003 16:56:55 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18ktFs-0005sT-00 for bug-guile@gnu.org; Mon, 17 Feb 2003 16:56:54 -0500 Original-Received: from sunny.pacific.net.au ([203.2.228.40]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18ktFr-0005jH-00 for bug-guile@gnu.org; Mon, 17 Feb 2003 16:56:51 -0500 Original-Received: from wisma.pacific.net.au (wisma.pacific.net.au [210.23.129.72]) by sunny.pacific.net.au with ESMTP id h1HLukMr001357 for ; Tue, 18 Feb 2003 08:56:47 +1100 (EST) Original-Received: from localhost (ppp94.dyn228.pacific.net.au [203.143.228.94]) by wisma.pacific.net.au with ESMTP id IAA28599 for ; Tue, 18 Feb 2003 08:56:44 +1100 (EST) Original-Received: from gg by localhost with local (Exim 3.35 #1 (Debian)) id 18ktEp-0000zZ-00; Tue, 18 Feb 2003 07:55:47 +1000 Original-To: bug-guile@gnu.org User-Agent: Gnus/5.090013 (Oort Gnus v0.13) Emacs/21.2 (i386-pc-linux-gnu) X-BeenThere: bug-guile@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Bug reports for GUILE, GNU's Ubiquitous Extension Language List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.bugs:674 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.bugs:674 --=-=-= In guile 1.6.3 built on a recent i386 debian, I struck a couple of cases where memoized macros seem to induce segmentation violations during a backtrace print. The files foo.scm and bar.scm are two examples, each independent, to be run as guile --debug -s foo.scm guile --debug -s bar.scm Each results in a partial backtrace printout then a segmentation violation, whereas naturally I hoped for a full printout. foo.scm has an obviously incorrect "let", as revealled by running without --debug. Still, it'd be nice to get a backtrace to locate the problem. For what it's worth, gdb suggests perhaps unmemocopy has gone into an infinite or very long recursion (the call under the "loop" label), apparently overflowing the stack (the faulting insn being a pushl). bar.scm produces a correct macro expansion, I believe. (Uncommenting the pretty-print in the file shows what's being executed, or is supposed to be executed.) But the record-accessor call is requesting an incorrect field. Running without --debug shows that error. For what it's worth, gdb suggests scm_unmemocar has been reached with an "env" list of just one element, whereas SCM_IFRAME is 1, for which an env of two or more elements is apparently expected. (But all this is a mystery to me, so I wouldn't necessarily trust that analysis). --=-=-= Content-Type: application/octet-stream Content-Disposition: attachment; filename=foo.scm (define my-macro (procedure->memoizing-macro (lambda (expr env) (list 'let expr)))) (my-macro 1 2 3) --=-=-= Content-Type: application/octet-stream Content-Disposition: attachment; filename=bar.scm (define let-toplevel* (procedure->memoizing-macro (lambda (expr env) (let-toplevel-transform expr 'let*)))) (define (let-toplevel-transform expr let-symbol) ;; EXPR is (define-toplevel ...), return a list (define foo #f) (define (top-def type expr) (list type (if (pair? (cadr expr)) (caadr expr) (cadr expr)) '#f)) ;; EXPR is (define-toplevel ...), return a list (set! foo ...) or ;; (set! foo (lambda ...)) (define (top-set expr) (if (pair? (cadr expr)) (list 'set! (caadr expr) (cons* 'lambda (cdadr expr) (cddr expr))) (cons 'set! (cdr expr)))) (let ((defs '())) (define (transform body) (map (lambda (expr) (cond ((eq? (car expr) 'define-toplevel) (set! defs (cons (top-def 'define expr) defs)) (top-set expr)) ((eq? (car expr) 'define-public) (set! defs (cons (top-def 'define-public expr) defs)) (top-set expr)) ((memq (car expr) '(let let*)) (cons* (car expr) (cadr expr) (transform (cddr expr)))) (else expr))) body)) (let ((trans (transform (cddr expr)))) (cons 'begin (append! defs (list (cons* let-symbol (cadr expr) trans))))))) ;; (use-modules (ice-9 pretty-print)) ;; (pretty-print ;; (let-toplevel-transform ;; '(let-toplevel* ;; ((rec-type (make-record-type "my-record" '(abc))) ;; (rec-new (record-constructor rec-type '(abc))) ;; (rec-abc (record-accessor rec-type 'xyz))) ;; (display "hello world\n")) ;; 'let*)) (let-toplevel* ((rec-type (make-record-type "my-record" '(abc))) (rec-new (record-constructor rec-type '(abc))) (rec-abc (record-accessor rec-type 'xyz))) (display "hello world\n")) --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit _______________________________________________ Bug-guile mailing list Bug-guile@gnu.org http://mail.gnu.org/mailman/listinfo/bug-guile --=-=-=--