Summary

Infinite continuation loop corrupts stack(?)

Metadata

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

Changes and comments

[2019-04-07 15:06:39 UTC] syn wrote:

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 :-)

[2019-04-07 15:51:26 UTC] sjamaan set difficulty to hard

[2019-04-07 15:51:26 UTC] sjamaan changed milestone from someday to 5.1

[2019-04-07 16:48:14 UTC] sjamaan wrote:

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).

[2019-04-07 16:48:14 UTC] sjamaan wrote:

1554648996557139

[2019-04-07 16:54:08 UTC] sjamaan wrote:

Perhaps 2dc0c5929abc398f1d344500fba9fc10ed4857cc is the culprit?

[2019-04-08 10:49:50 UTC] sjamaan wrote:

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.

[2019-04-08 10:55:16 UTC] sjamaan wrote:

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.

[2019-04-08 10:56:00 UTC] sjamaan wrote:

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

[2019-04-08 10:56:16 UTC] sjamaan wrote:

And also `(print (values))`

[2019-04-08 10:56:37 UTC] sjamaan wrote:

This was the same in CHICKEN 4 though!

[2019-04-08 12:41:03 UTC] sjamaan changed status from new to closed

[2019-04-08 12:41:03 UTC] sjamaan set resolution to fixed

[2019-04-08 12:41:03 UTC] sjamaan wrote:

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