[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: R: Using Lua with and without SO
- From: Thijs Schreijer <thijs@...>
- Date: Mon, 25 Nov 2013 17:05:43 +0000
> -----Original Message-----
> From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On
> Behalf Of Bob Schiavo
> Sent: maandag 25 november 2013 10:47
> To: 'Lua mailing list'
> Subject: R: R: Using Lua with and without SO
>
> Dear Thijs
> After some test, thanks to your hints, I've got what I was trying to do.
> Great!!
>
> Thank you very much
> Bob
>
>
> -----Messaggio originale-----
> Da: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] Per
> conto di Thijs Schreijer
> Inviato: venerdì 1 novembre 2013 20:21
> A: Lua mailing list
> Oggetto: RE: R: Using Lua with and without SO
>
> > If so, I think it is possible. You may try this:
> > Install a LUA_HOOKCOUNT hook into the Lua VM, which would be called
> > after the VM had executed LIMIT instructions.
> > If the LIMIT is reached, you may throw an error and the control would
> > return to your main program.
>
> There are some caveats here. See corowatch [1] for a Lua example, and
> check its readme for the caveats
>
> Thijs
>
> [1] https://github.com/Tieske/corowatch
>
In some of the presentations at the Lua workshop the HOOKCOUNT was also used to check for infinite loops etc. I think the McRobot [1] and the BACnet [2] had that mentioned in their presentations. In my own code [3], so far, I check the coroutine and kill (and log) it when it takes too long and continue.
But on my way home I gave it some more thought and actually came to the conclusion that it is a fairly dangerous thing to do. Whenever a coroutine has access to some shared data/element in the system, just terminating it might leave the system in some _unknown inconsistent state_. Therefore the only right thing to do is log as much info as needed to inform the code owner of the problem, and then terminate the application.
Thijs
[1] http://www.lua.org/wshop13.html#Jericke
[2] http://www.lua.org/wshop13.html#Schlephorst
[3] https://github.com/Tieske/corowatch