Skip to content

Commit

Permalink
sclang: ensure minimum stack size
Browse files Browse the repository at this point in the history
the sclang interpreter does not do any stack overflow checks. the stack
size of sclang threads is defaulted to 64, which is quite low. especially
it caused a gc corruption when running certain code in routines.

this patch increases the default stack size and adds a lower bound to the
stack size

Reported-by: Jonatan Liljedahl <lijon@kymatica.com>
Signed-off-by: Tim Blechmann <tim@klingt.org>
  • Loading branch information
timblechmann committed Mar 2, 2011
1 parent a76ff21 commit 01728b1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions common/Source/lang/LangPrimSource/PyrPrimitive.cpp
Expand Up @@ -2982,6 +2982,8 @@ int prThreadInit(struct VMGlobals *g, int numArgsPushed)
err = slotIntVal(c, &stacksize);
if (err) return err;

stacksize = std::max(stacksize, EVALSTACKDEPTH);

initPyrThread(g, thread, b, stacksize, (PyrInt32Array*)(slotRawObject(&g->thread->randData)),
slotRawFloat(&g->thread->beats), slotRawFloat(&g->thread->seconds), &g->thread->clock, true);

Expand Down
4 changes: 2 additions & 2 deletions common/build/SCClassLibrary/Common/Core/Thread.sc
Expand Up @@ -17,10 +17,10 @@ Thread : Stream {
var <>exceptionHandler;
var <executingPath, <oldExecutingPath;

*new { arg func, stackSize=64;
*new { arg func, stackSize=512;
^super.new.init(func, stackSize)
}
init { arg argFunc, argStackSize=64;
init { arg argFunc, argStackSize=512;
_Thread_Init
^this.primitiveFailed
}
Expand Down

0 comments on commit 01728b1

Please sign in to comment.