Arc Forumnew | comments | leaders | submitlogin
2 points by svetlyak40wt 3941 days ago | link | parent

Well, actually, even without threading, arcueid running code:

  (let i 0 (while t (prn "Still going: " i) (++ i)))

Fails with exception:

  arcueid: cont.c:58: __arc_mkcont: Assertion `(((struct vmthread_t *)(((struct cell *)(thr))->_obj))->spr) > (((struct vmthread_t *)(((struct cell *)(thr))->_obj))->stkbase)' failed.
after 7266 iterations.


2 points by dido 3937 days ago | link

The assertion error is a stack overflow. :) At present Arcueid makes use of a fixed-size stack within its virtual machine, and since the compiler still can't properly optimise tail recursion, your code overflows the stack.

-----

1 point by akkartik 3937 days ago | link

That was what I thought :) Is there a place where I can increase the size of the fixed stack? I looked for the limit in the code, but couldn't find it.

-----

3 points by dido 3936 days ago | link

src/vmengine.h:236:

#define TSTKSIZE 65536

Increase it as high as you like. :)

-----

1 point by akkartik 3936 days ago | link

Thanks!

Does it make sense to resize it on the fly when we discover we've overflowed the stack? Or are there potentially continuation pointers into the stack that would be non-trivial to track down?

-----

1 point by akkartik 3935 days ago | link

Yeah, no luck: https://github.com/akkartik/arcueid/commit/ae31b82540

-----

1 point by akkartik 3926 days ago | link

Possibly relevant: http://wingolog.org/archives/2014/03/17/stack-overflow

-----