Skip to content

Fix shm_get_var() returning unwrapped IS_REFERENCE - #25879

Open
hohphu8 wants to merge 1 commit into
php:PHP-8.4from
hohphu8:fix-sysvshm-unwrap-reference
Open

hohphu8 wants to merge 1 commit into
php:PHP-8.4from
hohphu8:fix-sysvshm-unwrap-reference

Conversation

@hohphu8

@hohphu8 hohphu8 commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant