-
Notifications
You must be signed in to change notification settings - Fork 94
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
Segmentation fault merging keys of maps containing maps #200
Comments
I've reduced this to:
|
Removing Thank you for reporting this. |
The problem is here I think: void ds_htable_put(ds_htable_t *table, zval *key, zval *value)
{
ds_htable_bucket_t *bucket;
// Attempt to find the bucket or initialize it as a new bucket.
bool found = ds_htable_lookup_or_next(table, key, &bucket);
// If found, destruct the current value so that we can replace it.
if (found) {
zval_ptr_dtor(&bucket->value);
}
if (value) {
ZVAL_COPY(&bucket->value, value);
}
} If found is true but value is NULL, then a stale zval will be in I think, add // If found, destruct the current value so that we can replace it.
if (found) {
zval_ptr_dtor(&bucket->value);
ZVAL_UNDEF(&bucket->value);
} At least this fixes the issue for me. |
Filed a PR: #202 |
Fix #200: Segmentation fault merging keys of maps containing maps
Maybe this is already done, but should there be regressions tests added ffor the two issues @nielsdos merged PRs for? |
I've added them here and tagged the tests as v1.5.0: php-ds/tests@c16f1ad |
Thanks for your work on this! |
I've noticed an add behavior working with Maps nested as values of a different Map. I merge the keys of the maps and then try to access one of the nested maps. The error is usually
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 99048189440 bytes) in ...
, however I've also seen the process ending with a segmentation fault as well.The behavior is odd. It seems to depend on the destruction of the resulting merged set of keys:
You can also achieve the same result by just using the single map
$mapInstance1
for all the calls instead.I'm running PHP 8.2.13 on Manjaro 23.1.0 x64. I've also tried the same in the docker image php:8.1.8-apache. The Ds 1.4.0 extension was installed in both cases.
The text was updated successfully, but these errors were encountered: