lua-users home
lua-l archive

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

> -----Original Message-----
> From: [] 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: [] 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]

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.