RE: Stack corruption on repetitive C to Lua calls, while thread is suspended (yield)

  • From: Alexandros Stergiakis <Alexandros.Stergiakis@xxxxxxxxxx>
  • To: "luajit@xxxxxxxxxxxxx" <luajit@xxxxxxxxxxxxx>
  • Date: Tue, 24 Sep 2013 23:37:19 +0000

Good idea Mike. Though there is an annoying catch in this case: I lose local 
variable scope, that I could use to communicate information from callback back 
to normal thread flow (and vice versa). Using global is tricky in my 
application because global is shared between multiple concurrent threads. Still 
if I have no other choice, I'll figure out a way using global or the registry.

One remark maybe worth mentioning is that the issue manifests only if there is 
a lua_call in the callback function. Assignments and the such do not trigger 
the problem.

Thanks for your help
Alex
________________________________________
From: luajit-bounce@xxxxxxxxxxxxx [luajit-bounce@xxxxxxxxxxxxx] on behalf of 
Mike Pall [mike-1309@xxxxxxxxxx]
Sent: Wednesday, September 25, 2013 2:23
To: luajit@xxxxxxxxxxxxx
Subject: Re: Stack corruption on repetitive C to Lua calls, while thread is 
suspended (yield)

Alexandros Stergiakis wrote:
> So, is there any other way (or common practice) to return to lua
> space to execute code without losing the state of the suspended
> thread?

Use the main lua_State or an extra lua_State.

--Mike


Other related posts: