[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Yielding coroutines from C using coco patch
- From: Mike Pall <mikelu-0901@...>
- Date: Sun, 18 Jan 2009 18:27:17 +0100
Tobias Markmann wrote:
> Yeah...that took the job. Using lua_newcthread() now but running in other
> problems now. Without any calling of my function that is yielding i
> get EXC_BAD_ACCESS if i try to execute my lua script which ran nice before
> using lua_newcthread() instead of lua_newthread().
>
> Here is some piece of backtrace and i'm running all that stuff on an intel
> mac.
>
> > (gdb) bt
> >
> #0 0x003c059c in matchl ()
> [...]
It looks like you're using LPeg. The default configuration wastes
an awful amount of stack space. Matching some patterns with
captures can consume up to 40K of stack space.
You seem to be nesting calls to LPeg from capture callbacks. This
quickly exceeds the default stack space of 60K for Coco coroutines (*).
(*) Lua itself has a rather small stack usage, so 60K is usually
more than sufficient.
Four solutions:
- Either reduce MAXBACK and IMAXCAPTURES in the LPeg sources to
some reasonable number,
- or increase the default stack size (pass it to lua_newcthread or
use luaCOCO_cstacksize),
- or don't nest calls to LPeg that deeply,
- or don't use LPeg from coroutines.
--Mike