-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Assertion `(flag & (1<<3)) == 0' failed. #10251
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
Comments
I confirm this happens on 8.1 and higher. Analysis: Upon attempting to store the empty string in the magic set method we first reach this code php-src/Zend/zend_object_handlers.c Lines 549 to 551 in 047c978
but the strings str and member are actually equal content-wise (their pointers are different, but the characters are the same: both the empty string). This shouldn't happen because of the string equality check above. Later we execute the following: php-src/Zend/zend_object_handlers.c Line 571 in 047c978
And now a new entry isn't actually added because the first snippet I linked added it. Therefore the assertion fails. Cause: The following check should've prevented this: php-src/Zend/zend_object_handlers.c Lines 537 to 540 in 047c978
But it turns out that the hash of str is zero here! I did a quick test by changing ZSTR_H(str) to zend_string_hash_val(str) and now the OP's code no longer crashes, indicating that the hash being zero is indeed the problem.
|
I would expect that any empty string to be "optimized" to the interned |
Yeah it also breaks with bitwise |
The line comparing hashes should just be dropped. |
I see, I'll make a PR for that change this afternoon. |
zend_get_property_guard previously assumed that at least "str" has a pre-computed hash. This is not always the case, for example when a string is created by bitwise operations, its hash is not set. Instead of forcing a computation of the hashes, drop the hash comparison.
Co-authored-by: Changochen <[email protected]>
Description
The following code:
Resulted in this output:
Build config:
PHP Version
PHP 8.3.0-dev
Operating System
No response
The text was updated successfully, but these errors were encountered: