[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #33362] Segfault with let and a case-lambda that calls another case
From: |
Stefan Israelsson Tampe |
Subject: |
[bug #33362] Segfault with let and a case-lambda that calls another case |
Date: |
Thu, 09 Jun 2011 20:15:58 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:2.0.0) Gecko/20100101 Firefox/4.0 |
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/
- [bug #33362] Segfault with let and a case-lambda that calls another case,
Stefan Israelsson Tampe <=