[Date Prev][Date Next][Thread Prev][Thread Next]
- 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: email@example.com [mailto:firstname.lastname@example.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.
> Thank you very much
> -----Messaggio originale-----
> Da: email@example.com [mailto:firstname.lastname@example.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  for a Lua example, and
> check its readme for the caveats
>  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  and the BACnet  had that mentioned in their presentations. In my own code , 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.