Repository navigation
Fix GH-20503: Assertion failure with ext/date DateInterval property hash construction - #20720
Conversation
3a6784b to
8fc8584
Compare
There was a problem hiding this comment.
Thank you @heathdutton! The approach looks right, but please check comments. (Edit: Please change the base of the PR to PHP-8.3. The branch is based on 8.3, but not the PR.)
|
NB: In master, |
2af857e to
6ec27cd
Compare
9b65615 to
6dfc863
Compare
|
I tried adding the refcount check to get_properties_interval, but it leaks memory - the duplicated HashTable has no owner to free it. Other routes I tried produced ABI break, so I reverted a bit to get us passed the block. The ABI break label no longer applies. |
6dfc863 to
f5bd733
Compare
|
Reworked per your suggestion. A direct self-reference now ends in "Maximum stack depth exceeded", same as DateTime. Moved the base to PHP-8.4 since 8.3 is security-only now. Mind another look when you get a chance? |
57ad95f to
358f3aa
Compare
|
Thank you! |
* PHP-8.4: [ci skip] NEWS Fix phpGH-20503: Assertion failure with ext/date DateInterval property hash (php#20720)
* PHP-8.5: [ci skip] NEWS Fix phpGH-20503: Assertion failure with ext/date DateInterval property hash (php#20720)
A DateInterval that references itself trips an assertion in
json_encode()on debug builds.date_object_get_properties_intervalwrites into the properties table in place. Whilejson_encode()walks the cycle, that table is shared (refcount > 1), sozend_hash_str_update()asserts.Now the handler separates the table first and writes the copy back to
obj->properties, so it doesn't leak.A direct self-reference ends in "Maximum stack depth exceeded" now, same as DateTime. A cycle through an array still reports "Recursion detected".
Fixes GH-20503