orc-lang / orc

Orc programming language implementation
https://orc.csres.utexas.edu/
BSD 3-Clause "New" or "Revised" License
40 stars 3 forks source link

Java Stack overflow caused by lazy closure resolution #112

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Procedure to Repeat:
1. Run certain programs such as the lazy list examples. With a long enough list 
it will crash.

Expected / Actual Results:
Running / Crashing with a Java stack overflow in the closure resolution process.

Version and Platform:
SVN r3122

Original issue reported on code.google.com by arthur.peters on 29 Nov 2012 at 9:11

GoogleCodeExporter commented 9 years ago
Here is an example program that causes a stack overflow due to lazy resolution:

type Step = Empty() | Item(_, _)

def cons(x, s) = lambda () = Item(x, s)
val nil = lambda () = Empty()

def mapStream(f, s) = lambda () = mapStep(s())
def mapStep(f, Empty()) = Empty()
def mapStep(f, Item(x, t)) = Item(f(x), mapStream(f, t))

def zipStreams(f, s, t) = lambda () = zipSteps(f, s(), t())
def zipSteps(f, _, Empty()) = Empty()
def zipSteps(f, Empty(), _) = Empty()
def zipSteps(f, Item(x, s), Item(y, t)) = Item(f(x,y), zipStreams(f, s, t))

def sumStreams(s, t) = zipStreams((+), s, t)

def fib() = sumStreams(cons(0, fib), cons(0, cons(1, fib)))()

def metroStep(Empty()) = -1
def metroStep(Item(x, s)) = x | Rwait(1000) >> metroStream(s)
def metroStream(s) = s() >i> metroStep(i)

def nats(n) = lambda () = Item(n, nats(n+1))

metroStream(fib)

Original comment by dkitc...@gmail.com on 1 Dec 2012 at 6:15

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r3161.

Original comment by arthur.peters on 20 Jan 2013 at 6:46