lua-users home
lua-l archive

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


On Sun, Feb 28, 2021 at 10:37 PM bel <bel2125@gmail.com> wrote:

> It seems I can create a simple Lua code that does not return after pcall:
>
> co = coroutine.create(function () my_pcall(coroutine.yield) end);
> coroutine.resume(co);
> print(coroutine.status(co)); -- dead ... but no exception or other issue
>
> Corresponding C code for "my_pcall" - I would not think this is "misbehaved":
>
> int my_pcall(lua_State *L)
> {
>   lua_pcall(L, lua_gettop(L)-1, 0, 0);
>   assert(0);
>   return 0;
> }
>
> Maybe Lua raised an error in coroutine.yield (where does this error go?).
> But it still did not continue after lua_pcall - the assert is not triggered.

This is not what I experience using Lua 5.3. What I get is error
"attempt to yield across a C-call boundary" pushed on stack by
lua_pcall(), exactly like the manual states. Whether assert() is
"triggered" is another matter, check the NDEBUG define in your
toolchain.

Cheers,
V.