### Description The following code: ```php <?php class C { function __serialize() { global $mem; shm_detach($mem); } } $mem = shm_attach(1); shm_put_var($mem, 1, new C); ``` Resulted in this output: ``` php: /tmp/php-asan/ext/sysvshm/sysvshm.c:398: zend_long php_check_shm_data(sysvshm_chunk_head *, zend_long): Assertion `ptr' failed. ``` ### PHP Version PHP 8.5.0-dev ### Operating System _No response_
Activity
cmb69 commentedon Oct 25, 2024
Yeah, destructors can be so destructive.
In this case we may swap the check and the serialization, or maybe duplicate the check after serialization:
php-src/ext/sysvshm/sysvshm.c
Lines 248 to 257 in 922bd2f
ndossche commentedon Oct 25, 2024
Probably just duplicate the check because we also shouldn't attempt to serialize if it's already been destroyed
Fix phpGH-16591: Assertion error in shm_put_var
Fix GH-16591: Assertion error in shm_put_var
Merge branch 'PHP-8.2' into PHP-8.3
Merge branch 'PHP-8.3' into PHP-8.4
Merge branch 'PHP-8.4'
Fix phpGH-16591 test leaking shared memory
Fix phpGH-16591 test leaking shared memory
Fix phpGH-16591 test leaking shared memory
Fix phpGH-16591 test leaking shared memory
Fix phpGH-16591 test leaking shared memory
Fix phpGH-16591 test leaking shared memory