Skip to content

Fix prop info fetching from prop slot with added hooks #18271

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

Closed
wants to merge 1 commit into from

Conversation

iluuu1994
Copy link
Member

Fixes GH-18268

@iluuu1994 iluuu1994 requested a review from Copilot April 7, 2025 15:36
@iluuu1994 iluuu1994 requested a review from dstogov as a code owner April 7, 2025 15:36
Copilot

This comment was marked as off-topic.

Copy link
Member

@arnaud-lb arnaud-lb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! Looks good to me!

@iluuu1994
Copy link
Member Author

Oops indeed. ^^ I should have tested this, but at least we have a test now. 🙂

@@ -203,7 +203,7 @@ ZEND_API void ZEND_FASTCALL zend_objects_store_del(zend_object *object) /* {{{ *

ZEND_API ZEND_COLD zend_property_info *zend_get_property_info_for_slot_slow(zend_object *obj, zval *slot)
{
uintptr_t offset = (uintptr_t)slot - (uintptr_t)obj->properties_table;
uintptr_t offset = (uintptr_t)slot - (uintptr_t)obj;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this should be a macro in zend_compile.h ? e.g. somewhere here:

php-src/Zend/zend_compile.h

Lines 462 to 469 in bd43334

#define OBJ_PROP(obj, offset) \
((zval*)((char*)(obj) + offset))
#define OBJ_PROP_NUM(obj, num) \
(&(obj)->properties_table[(num)])
#define OBJ_PROP_TO_OFFSET(num) \
((uint32_t)(XtOffsetOf(zend_object, properties_table) + sizeof(zval) * (num)))
#define OBJ_PROP_TO_NUM(offset) \
(((offset) - OBJ_PROP_TO_OFFSET(0)) / sizeof(zval))

I think it's better to place all those implementation details in a single place

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do. OBJ_PROP_SLOT_TO_OFFSET()?

Copy link
Member

@nielsdos nielsdos Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

@iluuu1994 iluuu1994 closed this in 6d458ca Apr 8, 2025
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.

3 participants