Uh oh!
There was an error while loading. Please reload this page.
Fix GH-21831: Disallow SplObjectStorage mutation during getHash() - #21835
Conversation
Girgias
left a comment
There was a problem hiding this comment.
I'm not sure I like this approach, but not sure how what I would want the behaviour to be is achievable.
Ideally one shouldn't be able to mess with the state from the getHash() method, as it's meant to be somewhat of a pure function.
prateekbhujel
commented
Apr 23, 2026
Yeah, I agree with that.
|
Girgias
commented
Apr 23, 2026
I think it would be cleaner to just change what getHash() is allowed to do, considering you are already targeting master and this seems very artificial so not sure it's worth backporting |
c261f36 to
f77542eCompareprateekbhujel
commented
Apr 29, 2026
@Girgias pushed that version now. I changed it so mutation during |
Girgias
left a comment
There was a problem hiding this comment.
Thank you for the new approach, I think this is better suited.
Uh oh!
There was an error while loading. Please reload this page.
f77542e to
3ea546aCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
3ea546a to
b1d0012Compareb1d0012 to
09a7ec5CompareUh oh!
There was an error while loading. Please reload this page.
FixesGH-21831.
getHash()runs whileSplObjectStorageis looking up an object. Letting it mutate a storage from there is unsafe, because the caller may still be iterating the table that just changed underneath it.This makes that fail immediately with an
Errorinstead of trying to handle it one caller at a time.The existing concurrent deletion tests now cover the new rule, and GH-21831 has a direct regression test. This targets master, so the behavior change is also noted in
UPGRADING.Tested with:
sapi/cli/php run-tests.php -q ext/spl/tests/SplObjectStorage