lua-users home
lua-l archive

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


2010/12/20 Patrick Donnelly <batrick@batbytes.com>
On Sun, Dec 19, 2010 at 2:39 PM, pk pk <pkairevent@gmail.com> wrote:
> While trying to implement LuaThread 1.1 (by Diego Nehab) to Lua 5.2 alpha
> under linux 2.6.x, I'm always getting segfault in function
> luaD_rawrunprotected.
> It arises when im launching lua like this: lua -e "print(123)"
>
> When I'm commenting parts, that locking/unlocking lua_State mutex,
> segfault disappears! I dont know why, need help!
>
> here is a patch file that implements only problem part:
> http://pastebin.com/aipzPv3n
>
> commenting this parts: lua_lock(L), lua_unlock(L)
> segfault appears here:   LUAI_TRY(L, &lj,    (*f)(L, ud);  );

LuaThread, when I used it, segfaulted in many interesting ways in Lua
5.1. I doubt it has to do with Lua 5.2. You should look at the other
pre-emptive threading solutions that exist for Lua. I don't think
LuaThread is even being maintained anymore.

--
- Patrick Donnelly

About 5.1 i have no complaints, it works well with right mutex usage.
Maybe you accidentally forgot to lock some global variables access parts?

I am writing my own solution, using LuaThread as basis, and I am almost done, except this final segfault.
My solution have destructor and cancel method(pthread_cancel), thread implemented as userdata.
if you are interested, i can share code under public domain, it will be good if someone with fresh view will look at it.

Anyway, problem still exists, I tried to implement my code for 5.1 - there is no segfault.
Also, i noticed, that new segfault appears, if lua_call is replaced by lua_pcall in thread start function in LuaThread.
This errror appears only in 5.2 version.