Fix SplObjectStorage getHash() guard leaking across a bailout#22308
Closed
iliaal wants to merge 1 commit into
Closed
Fix SplObjectStorage getHash() guard leaking across a bailout#22308iliaal wants to merge 1 commit into
iliaal wants to merge 1 commit into
Conversation
Member
|
A much nicer way is likely to reset spl_object_storage_get_hash_depth on request init/shutdown. |
58eada0 to
3fc40d5
Compare
Contributor
Author
|
Agreed, cleaner. Reset the counter in SPL's existing RINIT and dropped the zend_try/catch. Folded into PHP_RINIT(spl) rather than a new per-extension hook, and RINIT over RSHUTDOWN so a worker that skipped a clean shutdown still starts at zero. |
ndossche
reviewed
Jun 15, 2026
ndossche
left a comment
Member
There was a problem hiding this comment.
You need a specific skipif include for the usage of php_cli_server_start in your test
The getHash() recursion guard increments a request-persistent counter around the userland getHash() call but decrements it only on the normal return path. A bailout inside an overridden getHash() (out-of-memory, timeout, or any fatal) skips the decrement, and the counter is never reset per request, so on a persistent SAPI every later request on the same worker wrongly throws "Modification of SplObjectStorage during getHash() is prohibited". Reset the counter in the SPL request init so each request starts at zero regardless of how the previous one exited.
3fc40d5 to
c6ff5fc
Compare
Contributor
Author
|
Moved it to ext/spl/tests/ and added the php_cli_server.inc availability guard to SKIPIF. |
ndossche
approved these changes
Jun 15, 2026
ndossche
left a comment
Member
There was a problem hiding this comment.
I think this is also okay to go into 8.4.
Contributor
Author
Member
|
Ah okay, apologies. Good to go then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.