From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Neil Jerram Newsgroups: gmane.lisp.guile.bugs,gmane.lisp.guile.devel Subject: Re: Can't make a stack from a continuation Date: Thu, 25 Nov 2004 19:43:49 +0000 Message-ID: <41A635F5.2030303@ossau.uklinux.net> References: <41A23580.6070702@ossau.uklinux.net> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020406000605050301010404" X-Trace: sea.gmane.org 1101411941 13957 80.91.229.6 (25 Nov 2004 19:45:41 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 25 Nov 2004 19:45:41 +0000 (UTC) Cc: bug-guile@gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Thu Nov 25 20:45:27 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CXPYU-0003Hn-00 for ; Thu, 25 Nov 2004 20:45:26 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CXPhh-000386-He for guile-bugs@m.gmane.org; Thu, 25 Nov 2004 14:54:57 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CXPhW-00033H-KX for bug-guile@gnu.org; Thu, 25 Nov 2004 14:54:46 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CXPhU-00032H-G6 for bug-guile@gnu.org; Thu, 25 Nov 2004 14:54:44 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CXPhU-00032E-Bt; Thu, 25 Nov 2004 14:54:44 -0500 Original-Received: from [80.84.72.33] (helo=mail3.uklinux.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CXPWz-0005RY-Qg; Thu, 25 Nov 2004 14:43:54 -0500 Original-Received: from laruns (host81-130-122-81.in-addr.btopenworld.com [81.130.122.81]) by mail3.uklinux.net (Postfix) with ESMTP id F19F9409FA6; Thu, 25 Nov 2004 19:43:52 +0000 (UTC) Original-Received: from [127.0.0.1] (laruns [127.0.0.1]) by laruns (Postfix) with ESMTP id 2937D6F6C8; Thu, 25 Nov 2004 19:43:50 +0000 (GMT) User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041007 Debian/1.7.3-5 X-Accept-Language: en Original-To: guile-devel@gnu.org In-Reply-To: <41A23580.6070702@ossau.uklinux.net> X-BeenThere: bug-guile@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.bugs:2134 gmane.lisp.guile.devel:4433 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:4433 This is a multi-part message in MIME format. --------------020406000605050301010404 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Neil Jerram wrote: > neil@laruns:~$ guile -q > guile> (version) > "1.6.4" > guile> (call-with-current-continuation make-stack) > Segmentation fault I believe I have the fix for this (diffs attached for 1.6.x). Would anyone who feels half-confident in this area please review? Thanks, Neil --------------020406000605050301010404 Content-Type: text/x-patch; name="stacks.c.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="stacks.c.diff" Index: libguile/stacks.c =================================================================== RCS file: /cvsroot/guile/guile/guile-core/libguile/stacks.c,v retrieving revision 1.64.2.4 diff -u -u -r1.64.2.4 stacks.c --- libguile/stacks.c 15 Mar 2002 10:33:37 -0000 1.64.2.4 +++ libguile/stacks.c 25 Nov 2004 19:43:20 -0000 @@ -162,10 +162,11 @@ if (SCM_EVALFRAMEP (*dframe)) { scm_t_debug_info * info = RELOC_INFO (dframe->info, offset); - n += (info - dframe->vect) / 2 + 1; + scm_t_debug_info * vect = RELOC_INFO (dframe->vect, offset); + n += (info - vect) / 2 + 1; /* Data in the apply part of an eval info frame comes from previous stack frame if the scm_t_debug_info vector is overflowed. */ - if ((((info - dframe->vect) & 1) == 0) + if ((((info - vect) & 1) == 0) && SCM_OVERFLOWP (*dframe) && !SCM_UNBNDP (info[1].a.proc)) ++n; @@ -174,7 +175,7 @@ ++n; } if (dframe && SCM_VOIDFRAMEP (*dframe)) - *id = dframe->vect[0].id; + *id = RELOC_INFO (dframe->vect, offset) -> id; else if (dframe) *maxp = 1; return n; @@ -189,7 +190,8 @@ if (SCM_EVALFRAMEP (*dframe)) { scm_t_debug_info * info = RELOC_INFO (dframe->info, offset); - if ((info - dframe->vect) & 1) + scm_t_debug_info * vect = RELOC_INFO (dframe->vect, offset); + if ((info - vect) & 1) { /* Debug.vect ends with apply info. */ --info; @@ -206,9 +208,10 @@ } else { + scm_t_debug_info * vect = RELOC_INFO (dframe->vect, offset); flags |= SCM_FRAMEF_PROC; - iframe->proc = dframe->vect[0].a.proc; - iframe->args = dframe->vect[0].a.args; + iframe->proc = vect[0].a.proc; + iframe->args = vect[0].a.args; } iframe->flags = flags; } @@ -254,6 +257,7 @@ { scm_t_info_frame *iframe = iframes; scm_t_debug_info *info; + scm_t_debug_info *vect; static SCM applybody = SCM_UNDEFINED; /* The value of applybody has to be setup after r4rs.scm has executed. */ @@ -275,7 +279,8 @@ --iframe; } info = RELOC_INFO (dframe->info, offset); - if ((info - dframe->vect) & 1) + vect = RELOC_INFO (dframe->vect, offset); + if ((info - vect) & 1) --info; /* Data in the apply part of an eval info frame comes from previous stack frame if the scm_t_debug_info vector is @@ -292,7 +297,7 @@ iframe->flags |= SCM_FRAMEF_OVERFLOW; info -= 2; NEXT_FRAME (iframe, n, quit); - while (info >= dframe->vect) + while (info >= vect) { if (!SCM_UNBNDP (info[1].a.proc)) { @@ -462,8 +467,7 @@ } else if (SCM_CONTINUATIONP (obj)) { - offset = ((SCM_STACKITEM *) ((char *) SCM_CONTREGS (obj) + sizeof (scm_t_contregs)) - - SCM_BASE (obj)); + offset = (SCM_CONTREGS (obj) -> stack) - SCM_BASE (obj); #ifndef STACK_GROWS_UP offset += SCM_CONTINUATION_LENGTH (obj); #endif @@ -490,7 +494,7 @@ SCM_STACK (stack) -> frames = iframe; /* Translate the current chain of stack frames into debugging information. */ - n = read_frames (RELOC_FRAME (dframe, offset), offset, n, iframe); + n = read_frames (dframe, offset, n, iframe); SCM_STACK (stack) -> length = n; /* Narrow the stack according to the arguments given to scm_make_stack. */ @@ -546,8 +550,7 @@ } else if (SCM_CONTINUATIONP (stack)) { - offset = ((SCM_STACKITEM *) ((char *) SCM_CONTREGS (stack) + sizeof (scm_t_contregs)) - - SCM_BASE (stack)); + offset = (SCM_CONTREGS (stack) -> stack) - SCM_BASE (stack); #ifndef STACK_GROWS_UP offset += SCM_CONTINUATION_LENGTH (stack); #endif @@ -565,7 +568,7 @@ while (dframe && !SCM_VOIDFRAMEP (*dframe)) dframe = RELOC_FRAME (dframe->prev, offset); if (dframe && SCM_VOIDFRAMEP (*dframe)) - return dframe->vect[0].id; + return RELOC_INFO (dframe->vect, offset) -> id; return SCM_BOOL_F; } #undef FUNC_NAME @@ -625,8 +628,7 @@ } else if (SCM_CONTINUATIONP (obj)) { - offset = ((SCM_STACKITEM *) ((char *) SCM_CONTREGS (obj) + sizeof (scm_t_contregs)) - - SCM_BASE (obj)); + offset = (SCM_CONTREGS (obj) -> stack) - SCM_BASE (obj); #ifndef STACK_GROWS_UP offset += SCM_CONTINUATION_LENGTH (obj); #endif --------------020406000605050301010404 Content-Type: text/x-patch; name="eval.test.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="eval.test.diff" Index: test-suite/tests/eval.test =================================================================== RCS file: /cvsroot/guile/guile/guile-core/test-suite/tests/eval.test,v retrieving revision 1.6.2.1 diff -u -u -r1.6.2.1 eval.test --- test-suite/tests/eval.test 19 Jul 2001 20:49:34 -0000 1.6.2.1 +++ test-suite/tests/eval.test 25 Nov 2004 19:43:20 -0000 @@ -177,4 +177,26 @@ (map + '(1 2) '(3))) ))) +;;; +;;; continuations +;;; + +(with-test-prefix "continuation" + + (with-test-prefix "stacks/debugging" + + (debug-enable 'debug) + + (pass-if "make-stack" + (stack? (call-with-current-continuation make-stack))) + + (pass-if "stack-id" + (let ((id (call-with-current-continuation stack-id))) + (or (boolean? id) (symbol? id)))) + + (pass-if "last-stack-frame" + (pair? (call-with-current-continuation last-stack-frame))) + + )) + ;;; eval.test ends here --------------020406000605050301010404 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Bug-guile mailing list Bug-guile@gnu.org http://lists.gnu.org/mailman/listinfo/bug-guile --------------020406000605050301010404--