[php-src] PR #25879: Fix shm_get_var() returning unwrapped IS_REFERENCE
| From: | hohphu8 | Date: | Sat, 28 Nov 2026 17:28:59 +0000 |
| Subject: | [php-src] PR #25879: Fix shm_get_var() returning unwrapped IS_REFERENCE | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-41166@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25879
Author: hohphu8
shm_get_var() calls php_var_unserialize() directly into
return_value without unwrapping a top-level IS_REFERENCE. When a
self-referential object ($obj = new stdClass(); $obj->self = &$obj;, serialized
as O:8:"stdClass":1:{s:4:"self";R:1;}) is stored with
shm_put_var() and retrieved with shm_get_var(), return_value
remains an IS_REFERENCE, violating the non-by-ref internal function return convention
and triggering a Zend VM assertion failure in debug builds
(ZEND_ASSERT(!Z_ISREF_P(retval))).
Unwrap return_value via zend_unwrap_reference(return_value) when
Z_ISREF_P(return_value) is true after
PHP_VAR_UNSERIALIZE_DESTROY(var_hash), matching unserialize() in
ext/standard/var.c.
Added a regression test storing and retrieving a self-referential object via
shm_put_var() / shm_get_var().
Note: AI-assisted code audit; manually verified and reproduced locally.