[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua_close + IUP = crash?
- From: Rob Hoelz <rob@...>
- Date: Fri, 11 Jan 2013 09:08:17 +0100
On Fri, 11 Jan 2013 08:54:51 +0100
Rob Hoelz <rob@hoelz.ro> wrote:
> On Thu, 10 Jan 2013 23:41:47 -0800 (PST)
> mbul <mbul@arqa.ru> wrote:
>
> > Hi,
> > my program runs Lua scripts from multiple threads. It looks like
> > this:
> >
> > 1.
> > In my host program:
> >
> > ...
> > lvm1 = lua_open()
> > ...
> > lvm2 = lua_newthread()
> > ...
> >
> > 2.
> > Start a separate OS-thread that does the following:
> > ...
> >
> > lua_getfield (main, LUA_GLOBALSINDEX,
> > "main"); int lua_err = lua_qpcall(lvm2, main, 0, 0,
> > 0); if (lua_err)
> > {
> > script->FormatLuaErrMsg(lvm, lua_err);
> > return lua_err;
> > }
> > return 0;
> >
> >
> > Lua script code:
> >
> > function main()
> > require "iuplua"
> > dlg = iup.dialog
> > {
> > iup.vbox
> > {
> > iup.button{title="Button Very Long Text", size="50x"},
> > iup.button{title="short", expand="HORIZONTAL"},
> > iup.button{title="Mid Button", size="50x"}
> > }
> > ;title="IupDialog", font="Helvetica, Bold 14"
> > }
> >
> > -- Show the dialog and run the main loop
> > dlg:show()
> >
> > if (not iup.MainLoopLevel or iup.MainLoopLevel()==0) then
> > iup.MainLoop()
> > end
> > iup.Close()
> > end
> > 3.
> > When the thread is finished, the following occurs:
> > lua_close(lvm1) // lvm1 = lua_open()
> > and then an error ACCESS VIOLATION occurs. Error occurred while
> > releasing resources in Lua sources freeobj(L, curr);
> >
> > Got any ideas?
> >
> >
> >
> >
> >
> >
> > --
> > View this message in context:
> > http://lua.2524044.n2.nabble.com/lua-close-IUP-crash-tp7645673.html
> > Sent from the Lua-l mailing list archive at Nabble.com.
> >
>
> Hi mbul,
>
> You can't use OS threads with coroutines in Lua. Doing so will result
> in problems like you see here.
>
> -Rob
Also, if you want to use OS threads with Lua, here's a wiki page on
that subject: http://lua-users.org/wiki/ThreadsTutorial
You might want to ask yourself if you really need OS threads here,
though!
-Rob
Attachment:
signature.asc
Description: PGP signature