I'm not sure, though, whether this is a bug in Lua, or just that
you're not supposed to use lua_resume on the main thread.
You can only resume a coroutine that's in the right state, it either should not have started yet, or it should have yielded. You cannot resume a thread that resumed another one, a thread that resumes another one will only restart if the thread it resumed yields or exits.