[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Reentrant GC
- From: Philippe Verdy <verdyp@...>
- Date: Tue, 27 Nov 2018 11:31:08 +0100
Metafunction, not metamorphic. Damned Android substitution...
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.
I am concerned about an attacker setting a __gc metamethod that loops forever and can't be broken.
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!