lua-users home
lua-l archive

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


Hi Mike,

I'm integrating readline-based interactive lua interpreter into my event
framework and I'm getting random crashes with -jon.

Lua interpreter code is based on src/lua.c from lua-5.1.4 but I made
some changes to accommodate to a different event model. Basically,
I do lua_cpcall in readline callback.

Now, to the tricky part. Plain cfunction inside a loop turns off JIT so
I pass lua_State* pointer from LuaJIT to C before I start a loop and
then I use the saved pointer when I call a callback function from inside
the loop via FFI interface.

In other words, I call read_char() from the event loop using FFI, which
eventually calls readline_callback(char *line) and at this point I use
the saved lua_State* pointer to call lua_cpcall(L, &cpreadline, line).

Is this valid at all?

(If I call read_char() via plain cfunction interface, I don't see crashes
but JIT is turned off in this case).

It's x86-64 Linux, in case it matters.

Thanks,
Alex