-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
PHP extension 4.0 - cast from zend_obj #7720
Comments
P.S. no PR because of damned CLA. |
Thanks for taking a look at the new extension! Did this lead to an actual issue for you (eg. a SIGSEGV) or is this something you just saw from inspecting the code? I know extensions are supposed to use the pattern above. But we force the property count to zero, which prevents PHP from writing properties after the |
To leave a bit more info: in my testing, adding this line prevented PHP from writing to any memory after the protobuf/php/ext/google/protobuf/message.c Lines 71 to 72 in ffb2b53
This is probably not a totally kosher approach. I could imagine that it might break on a different major version of PHP, like PHP 8. If so, we should implement your fix. But if not, does it cause any harm to leave in for now? |
Also a note that if we do this, we also need to move the |
From code review, checking for PHP 8 compatibility
Yes, the zend_object must be first member in 5.x and last in 7.x Following PHP common practice seems better for code legibility, ad may also help for future version Ex:
|
I would rather avoid I'm reluctant to change the current code if it works in practice. But if we do need to change it, I'd rather change it for all PHP versions, rather than use |
The #if is mandatory, Message_read_property protocol must be different in php 7 (accepting a zval) and php 8 (accepting a zend_object). |
In php 8, the writer_property handler needs to return reference to the internal property. |
@remicollet any idea? |
@dstogov could you help here? |
I missed @TeBoring's point before. To clarify, in PHP7 the
Whereas in PHP8 it is:
Our message objects do not internally store |
The change for return value was not in 8.0, but in 7.4 From UPGRADING.INTERNALS
|
The The cast from |
Casting zend_object to Message * (or any other internal struct) is not the proper way
example:
The text was updated successfully, but these errors were encountered: