lua-users home
lua-l archive

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


p

On Apr 8, 2013 3:50 AM, "Satz Klauer" <satzklauer@googlemail.com> wrote:
Hi,

I have some C-code, that connects LUA to an existing application.
There are some new LUA-functions defined and announced via
lua_register() so that a user can call into the application out of its
LUA-script.

Beside of that the user can define a callback function within
LUA-script that can be called out of the application asynchronously,
means out of an own thread. Here the C-code fetches the function by
calling lua_getfield(), builds up the parameters of this function to
be called via lua_pushxxx() and then calls lua_call() - which
sometimes crashes.

My first idea: it is a threading/race condition problem, so I
encapsulated all LUA-to-C-functions and the C-to-LUA-callback with one
mutex. So now calling form LUA to my C-code and constructing the call
from my C-code back to LUA is done exclusively, none of these calls
can overlap anymore.

Unfortunately the same crash still happens. It can't be reproduced
easily, it happens only from time to time.

Any ideas what could be wrong?

Thanks!

Elmi