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

Tobias Heintz commented on THRIFT-1579:
---------------------------------------

We were experiencing the same bug using the vanilla 
{{TBinarySerializer::deserialize()}} function. This issue only occurs under two 
circumstances:
# The C extension is enabled.
# The size of the serialized string is less than 512 bytes.

When the first condition applies, the TBinarySerializer tries to be smart and 
drops the message header from the serialized string after serialization (to 
save some space I assume). Upon deserialization it writes a dummy header back 
to the transport, but when the second condition also applies this header never 
goes anywhere due to some evil internal object graph rewiring done by 
{{TBinaryProtocolAccelerated::__construct()}}.

I have attached a patch which fixes this behavior.

> PHP Extention - function thrift_protocol_read_binary not working from 
> TBinarySerializer::deserialize
> ----------------------------------------------------------------------------------------------------
>
>                 Key: THRIFT-1579
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1579
>             Project: Thrift
>          Issue Type: Bug
>          Components: PHP - Library
>    Affects Versions: 0.8
>         Environment: "Ubuntu Server Cloud Guest 11.10 (Oneiric Ocelot)" - 
> this for AWS
> Nginx + PHP5-FPM
>            Reporter: Sergei Labutin
>            Priority: Critical
>         Attachments: thrift-091-fix-php-binary-serialization.patch
>
>
> I copy class TBinarySerializer and change code:
>     $transport = new TMemoryBuffer();
>     $protocol = new TBinaryProtocolAccelerated($transport);
>     $transport->write($string_object);
>     $object = new $class_name();
>     $object->read($protocol);
>     return $object;
> This code is work. Function thrift_protocol_read_binary can't deserealize.
> 2012/04/16 17:38:52 [error] 1252#0: \*126088457 FastCGI sent in stderr: "PHP 
> Fatal error:  Uncaught exception 'TTransportException' with message 
> 'TMemoryBuffer: Could not read 512 bytes from buffer.' in 
> /usr/lib/php/transport/TMemoryBuffer.php:58
> Stack trace:
> #0 /usr/lib/php/transport/TBufferedTransport.php(126): 
> TMemoryBuffer->read(512)
> #1 [internal function]: TBufferedTransport->read(8192)
> #2 /usr/lib/php/protocol/TBinarySerializer.php(62): 
> thrift_protocol_read_binary(Object(TBinaryProtocolAccelerated), '\*\*\*\*\*', 
> false)
> #3 /*****/www/index.php(77): 
> TBinarySerializer::deserialize('???????????????...', '\*\*\*\*\*')
> #4 {main}
>   thrown in /usr/lib/php/transport/TMemoryBuffer.php on line 58" while 
> reading response header from upstream, client: \*\*\*\*\*, server: localhost, 
> request: "GET /?\*\*\*\*\* HTTP/1.1", upstream: "fastcgi://\*\*\*\*\*", host: 
> "\*\*\*\*\*"
> \*\*\*\*\* - private information, but here can't any mistake =)
> Object serelize from java.
> new TSerializer().serialize(request);



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to