New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Weird pointers issue in nested loops #12826
Comments
Can confirm, reverting cd53ce8 fixes this. |
This loops hangs forever: iter_pos is equal to nNumUsed (2) and can't move further: Lines 2419 to 2422 in e3de478
However, I find it odd because we are looping from p to end, which is from p to p+4 in the example code. Line 2410 in e3de478
which seems strange because now the number of used slots is equal to the number of elements, but we are still looping over all the buckets including the undef ones. |
This regressed in cd53ce8. The loop with `zend_hash_iterators_update` hangs forever because `iter_pos` can't advance to idx. This is because the `zend_hash_iterators_lower_pos` upper bound is `target->nNumUsed`, but that is set to `source->nNumOfElements`. That means that if there are holes in the array, we still loop over all the buckets but the number of bucket slots will not match. Fix it by changing the assignment.
Description
Hi,
I observe a weird issue in php 8.3.0 with the following (weird) code:
As expected, it outputs:
But if I unset, say
$test['a']
and$test['b']
before the loop, the server seems to enter some kind of infinite loop. Unsetting only one element or only few last elements does not seem to yield any problem. When looping by value$k => $v
everything is fine of course.The problem seems to come from
$test[$kk] = 0
assignment. If I comment it out, everything is fine again, whichever elements are unset.I've tested it on few servers, with the same result. The code works without any issue in php from 5.4 to 8.2.
PHP Version
PHP 8.3.0
Operating System
Various
The text was updated successfully, but these errors were encountered: