Opened 4 months ago

Closed 4 months 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 Changed 4 months ago by Moritz Heidkamp

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 Changed 4 months ago by sjamaan

Estimated difficulty: hard
Milestone: someday5.1

comment:3 Changed 4 months ago by sjamaan

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 4 months ago by sjamaan (previous) (diff)

comment:4 Changed 4 months ago by sjamaan

Perhaps 2dc0c5929abc398f1d344500fba9fc10ed4857cc is the culprit?

comment:5 Changed 4 months ago by sjamaan

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 Changed 4 months ago by sjamaan

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 Changed 4 months ago by sjamaan

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

comment:8 Changed 4 months ago by sjamaan

And also (print (values))

comment:9 Changed 4 months ago by sjamaan

This was the same in CHICKEN 4 though!

comment:10 Changed 4 months ago by sjamaan

Resolution: fixed
Status: newclosed

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

Note: See TracTickets for help on using tickets.