lua-users home
lua-l archive

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


Metafunction, not metamorphic. Damned Android substitution...

Le mar. 27 nov. 2018 à 11:29, Philippe Verdy <verdyp@gmail.com> a écrit :
There's a way to restrict that infinite loop so that the __gc metamorphic will not be systematically be called at each cycle but only after a growing delay (exponential growth) has passed. This will rapidly stop the infinite loop even if these objects get never finalized, and at least this will avoid consuming lot of CPU resources.

Le mar. 27 nov. 2018 à 10:30, Soni L. <fakedme@gmail.com> a écrit :
I am concerned about an attacker setting a __gc metamethod that loops forever and can't be broken.

On Tue, Nov 27, 2018, 04:31 Tim Hill <drtimhill@gmail.com wrote:


On Nov 26, 2018, at 8:54 PM, Philippe Verdy <verdy_p@wanadoo.fr> wrote:

If your __gc finlization metamethods makes more complex things requiring allocation of new resources, in my opinion the program has a design bug: these resources needed to free objects should have been allocated wit hthe object long before it gets dereferenced and then garbage collected for finalization. Finalization should not allocate memory except for very simple objects that have NO such __gc finalization routine (such as strings or simple preallocated buffers/indexed arrays).


Exactly. It seems to me the OP is concerned about temporary allocations during the __gc metamethod not being cleaned up until the next GC cycle. Well, welcome to the world of GC!

—Tim