lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello,

I recently created a patch to LuaCoco to add ARM support under uClibc.
I'm having a problem and I was hoping someone might be able to help
get me on the right track.

With my patch, all of the tests in the cotest directory pass.  I then
tried using the Coco version of Lua with a larger codebase I am
working on.  Most of the yield/resumes work without any issues.  But
when I get to a particular yield, I get an error about crossing a
metamethod/C-call boundary.  This yield should have been in a coco
coroutine, but it doesn't think it is.

I looked at every case where I call coroutine.create and
coroutine.wrap, and in none of those cases do I pass -1 for a
cstacksize, so I would expect every coroutine to be a coco one.  Also,
right before I call the offending yield I print the value of
coroutine.cstacksize() and it gives me 61440, which I would expect.
So at this point it thinks it is a coco coroutine as well.  But when
the code gets to luai_userstateyield() in lua_yield(), the LHASCOCO
macro returns false and so we try to do a non-coco yield instead.

Most of the calls to LHASCOCO do pass as I would expect, and I can't
find anything special about this particular coroutine.  Currently I
don't have a small test to exploit this issue, given the nature of it.
But I can try to create one.  I did make sure to recompile all of the
Lua C modules I am using, although I'm not sure if that would have
mattered.

Here is the code I used for adding ARM/uclibc support.  Perhaps the
issue lies in there.  Specifically, I am not sure why COCO_STACKADJUST
is needed in some cases and if I need it.

#define COCO_MAIN_PARAM     int _a, int _b, int _c, int _d, lua_State *L

#define COCO_PATCHCTX(coco, buf, func, stack, a0) \
 buf->__jmpbuf[21] = (int)(func); \
 buf->__jmpbuf[20] = (int)(stack); \
 buf->__jmpbuf[19] = (int)0; /* ebp */ \
 stack[0] = (size_t)(a0);

Any debugging suggestions would be appreciated.  Thanks.

--
Zachary P. Landau <kapheine@gmail.com>