[php-src] PR #22308: Fix SplObjectStorage getHash() guard leaking across a bailout

From: Date: Sun, 14 Jun 2026 17:12:47 +0000
Subject: [php-src] PR #22308: Fix SplObjectStorage getHash() guard leaking across a bailout
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-36423@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/22308 Author: iliaal The getHash() recursion guard bumps a request-persistent counter around the userland getHash() call but only decrements it on the normal return. A bailout inside an overridden getHash() (out of memory, timeout, any fatal) skips the decrement, and nothing resets the counter per request, so on a persistent SAPI every later request on the same worker wrongly throws "Modification of SplObjectStorage during getHash() is prohibited". Decrement inside a zend_catch and re-raise the bailout so the counter is balanced on every exit. ```php class P extends SplObjectStorage { public function getHash($o): string { ini_set('memory_limit', '2M'); str_repeat('a', 100 * 1024 * 1024); // OOM bailout return 'x'; } } (new P())->offsetSet(new stdClass()); // request 1 bails out (new SplObjectStorage())->offsetSet(new stdClass()); // later request, no override: throws before the patch ```

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