[php-src] PR #13758: Adjust GC threshold if num_roots higher than threshold after collection

From: Date: Tue, 19 Mar 2024 13:34:44 +0000
Subject: [php-src] PR #13758: Adjust GC threshold if num_roots higher than threshold after collection
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-25481@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/13758 Author: arnaud-lb This fixes an edge causing the GC to be triggered repeatedly. Destructors might add potential garbage to the buffer, so it may happen that num_root it higher than threshold after collection, thus triggering a GC run almost immediately. This can happen by touching enough objects in a destructor, e.g. by iterating over an array. If this happens again in the new run, and the threshold is not updated, the GC may be triggered again. The edge case requires specific conditions to be triggered and it must happen rarely in practice: - At least GC_THRESHOLD_TRIGGER objects must be collected during each run - At least GC_G(gc_threshold) objects must be touched (decref'ed from n+1 to n) by any destructor during each run to fill the buffer The fix is to increase the threshold if GC_G(num_roots) >= GC_G(gc_threshold) after GC. The threshold eventually reaches a point at which the second condition is not met anymore. The two included tests trigger 200 GC runs before the fix, and 2 after the fix (dtors always trigger a second run). Fixes https://github.com/php/php-src/issues/13670

« previous php.git-pulls (#25481) next »