thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (THRIFT-4373) Extending Thrift class results in "Attempt serialize from non-Thrift object"
Date Thu, 26 Oct 2017 06:15:00 GMT

    [ https://issues.apache.org/jira/browse/THRIFT-4373?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16220020#comment-16220020
] 

ASF GitHub Bot commented on THRIFT-4373:
----------------------------------------

Github user RobberPhex commented on a diff in the pull request:

    https://github.com/apache/thrift/pull/1401#discussion_r147052177
  
    --- Diff: lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp ---
    @@ -709,6 +715,9 @@ void binary_serialize(int8_t thrift_typeID, PHPOutputTransport&
transport, zval*
             throw_tprotocolexception("Attempt to send non-object type as a T_STRUCT", INVALID_DATA);
           }
           zval* spec = zend_read_static_property(Z_OBJCE_P(value), "_TSPEC", sizeof("_TSPEC")-1,
true);
    +      if (spec) {
    --- End diff --
    
    I think `Z_TYPE_P(prop) == IS_REFERENCE`


> Extending Thrift class results in "Attempt serialize from non-Thrift object"
> ----------------------------------------------------------------------------
>
>                 Key: THRIFT-4373
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4373
>             Project: Thrift
>          Issue Type: Bug
>          Components: PHP - Library
>    Affects Versions: 0.10.0
>         Environment: Linux 4.13.3-1-ARCH
> PHP 7.1.10
>            Reporter: Josip Sokcevic
>         Attachments: 0001-THRIFT-4373-Derefer-PHP-zval-_TSPEC.patch
>
>
> This happens when using php extension. thrift_protocol_write_binary will check Z_TYPE_P
of spec and expects to be array (IS_ARRAY). However, PHP7 will set it as reference (IS_REFERENCE).
> Example:
> {code}
> $s = new Serializer\TBinarySerializer();
> // Foo is a Thrift type class
> class FooExtended extends Foo {}
> $o = new Foo();
> $o2 = new FooExtended();
> // this works just fine:
> $s->serialize($o); // this uses thrift_protocol_write_binary if available
> // Next line throws \Thrift\Exception\TProtocolException if thrift_protocol_write_binary
is used
> // However, it doesn't break if no extension is available.
> $s->serialize($o);
> {code}
> Proposed solution is to dereference using ZVAL_DEREF before checking types (attached).
Alternative would be to mark struct type classes as final, but that break compatibility.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message