Opened 7 years ago

Closed 7 years ago

#1601 closed defect (fixed)

Infinite continuation loop corrupts stack(?)

Reported by: Moritz Heidkamp Owned by:
Priority: minor Milestone: 5.1
Component: unknown Version: 5.0.0
Keywords: Cc:
Estimated difficulty: hard

Description

This program:

(let ((loop #f))
  (call/cc (lambda (f)
             (set! loop f)))
  (print 123)
  (loop))

prints lines of "123" for a while until it aborts with this error:

[panic] Detected corrupted data in stack - execution terminated

Change History (10)

comment:1 by Moritz Heidkamp, 7 years ago

Just found out that adding an explicit (gc) to the loop fixes the problem. So apparently the GC doesn't realize that it needs to do its job here :-)

comment:2 by sjamaan, 7 years ago

Estimated difficulty: hard
Milestone: someday5.1

comment:3 by sjamaan, 7 years ago

In CHICKEN 4, we get an error that loop is invoked without any arguments. If I change the call so it's (loop loop), it does not error in C5.

This could point to a problem with the number of arguments the continuation is invoked versus how it is expected to be invoked. Strictly speaking, it shouldn't care about the number of arguments (given that it doesn't do anything with the value(s) returned by the call/cc call).

Last edited 7 years ago by sjamaan (previous) (diff)

comment:4 by sjamaan, 7 years ago

Perhaps 2dc0c5929abc398f1d344500fba9fc10ed4857cc is the culprit?

comment:5 by sjamaan, 7 years ago

I've also noticed that (receive (x) (call/cc (lambda (f) 1 (values))) (print x)) does not error out; it prints #<unspecified>, which is definitely wrong.

comment:6 by sjamaan, 7 years ago

That expands to (##core#let ((x (call/cc (lambda (f) (values))))) (print x)) and this doesn't work. An explicit call to call-with-values works.

comment:7 by sjamaan, 7 years ago

Simplified, this gives unspecified too: (let ((x (values))) (print x))

comment:8 by sjamaan, 7 years ago

And also (print (values))

comment:9 by sjamaan, 7 years ago

This was the same in CHICKEN 4 though!

comment:10 by sjamaan, 7 years ago

Resolution: fixed
Status: newclosed

Fixed with 3e0f640ecf22f6be7af1947b875132415556ca5b (not signed-off, but discussed at SaarCHICKEN)

Note: See TracTickets for help on using tickets.