unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Stefan Israelsson Tampe <INVALID.NOREPLY@gnu.org>
To: "Göran Weinholt" <goran@weinholt.se>,
	"Stefan Israelsson Tampe" <stefan.itampe@gmail.com>,
	bug-guile@gnu.org
Subject: [bug #33362] Segfault with let and a case-lambda that calls another case
Date: Thu, 09 Jun 2011 20:15:58 +0000	[thread overview]
Message-ID: <20110609-201557.sv78157.7614@savannah.gnu.org> (raw)
In-Reply-To: <20110521-173440.sv2373.49729@savannah.gnu.org>

Follow-up Comment #1, bug #33362 (project guile):

Entering the offending code in a function, f,  and disassembled it 
leading to, 
> ,x f
...
Disassembly of #<procedure t (x) | (x y)>:

   0    (br-if-nargs-ne 0 1 :L997)      ;; -> 21
   6    (reserve-locals 0 1)            
   9    (local-ref 0)                   ;; `x'
  11    (object-ref 1)                  ;; y  
  13    (local-set 1)                   
  15    (local-set 0)                   ;; `x'
  17    (br :L998)                      ;; -> 23
  21    (assert-nargs-ee/locals 2)     
...

This results in error behavior as stated. Now increasing the reservation by
one in (reserve-locals 0 1) with a hex editor fixes the problem and the object
code runs just fine. So probably when y is used in the case lambda with fewer
used arguments the compiler misses the number of reservations of the stack
that is needed. So later when the code calls a function and stack space is
needed some undefined behavior results e.g. a crash.

Solution?
The problem is in the tree-il compilation code. The allocation
of number of locals needs to be adjusted for the self referential parts.
consider to store the suggested value, v, 
as (alloc new v ncarg). Then when compiling the a self referential call with
narg elements. Then we need to update acording to: 

  new = max(new,v + max(0,narg - ncarg))

Safest is to parse the tree-il subcode for self referentials
and update the local-variables and argument stack layout acordingly. 

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?33362>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




  reply	other threads:[~2011-06-09 20:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-21 15:34 [bug #33362] Segfault with let and a case-lambda that calls another case Göran Weinholt
2011-06-09 20:15 ` Stefan Israelsson Tampe [this message]
2011-06-17 15:15   ` Andy Wingo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110609-201557.sv78157.7614@savannah.gnu.org \
    --to=invalid.noreply@gnu.org \
    --cc=bug-guile@gnu.org \
    --cc=goran@weinholt.se \
    --cc=stefan.itampe@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).