You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Jake Farrell (JIRA)" <ji...@apache.org> on 2011/08/13 23:17:27 UTC

[jira] [Updated] (THRIFT-1240) TBinarySerializer.php invalid serialization due to TBufferTransport not flushing last chunk of data into TMemoryBuffer

     [ https://issues.apache.org/jira/browse/THRIFT-1240?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jake Farrell updated THRIFT-1240:
---------------------------------

    Fix Version/s:     (was: 0.6.1)
                   0.8

> TBinarySerializer.php invalid serialization due to TBufferTransport not flushing last chunk of data into TMemoryBuffer
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: THRIFT-1240
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1240
>             Project: Thrift
>          Issue Type: Bug
>          Components: PHP - Library
>    Affects Versions: 0.6.1
>         Environment: Cent OS and Mac OS 10.5
>            Reporter: Marimuthu Ponnambalam
>            Priority: Critical
>              Labels: TBinarySerializer, invalid, serialization
>             Fix For: 0.8
>
>         Attachments: TBinarySerializer.php, simple.thrift, testsimple.php
>
>
> Simple Serialization errors out, due to the TBufferTransport not flushing the data into TMemoryBuffer after $object->write($protocol) in TBinarySerializer.
> Please find the error output of my test program below. It fixed after I added the following line on the serialize method in TBinarySerializer.
> $protocol->getTransport()->flush();
> This because of TBinaryProtocolAccelerated internally wraps TMemoryBuffer within TBufferTransport in its constructor.
>  TBufferTransport write only if the wbuf_ is full (512 bytes) into TMemoryBuffer. Hence data smaller than 512 will not get written into TMemoryBuffer. While getting serialized data from TMemoryBuffer it might not have the last chunk of data which is less than 512 bytes. 
> This outputs invalid serialized data 
> TestSchema$ php testsimple.php 
> Serialized  .
>              mari
> Fatal error: Uncaught exception 'TTransportException' with message 'TMemoryBuffer: Could not read 512 bytes from buffer.' in /Users/mponnambalam/work/eclipse/workspace/thrift0.6.1/lib/php/src/transport/TMemoryBuffer.php on line 58
> TTransportException: TMemoryBuffer: Could not read 512 bytes from buffer. in /Users/mponnambalam/work/eclipse/workspace/thrift0.6.1/lib/php/src/transport/TMemoryBuffer.php on line 58
> Call Stack:
>     0.0003     636976   1. {main}() /Users/mponnambalam/work/eclipse/workspace/TestSchema/testsimple.php:0
>     0.0043    1509728   2. TBinarySerializer::deserialize() /Users/mponnambalam/work/eclipse/workspace/TestSchema/testsimple.php:47
>     0.0043    1511808   3. thrift_protocol_read_binary() /Users/mponnambalam/work/eclipse/workspace/thrift0.6.1/lib/php/src/protocol/TBinarySerializer.php:62
> thrift_protoco_read_binary disabled  ( I commented extension in thrift_protocol.ini) 
>  
> TestSchema$ php testsimple.php 
> Serialized  .
> Fatal error: Uncaught exception 'TTransportException' with message 'TMemoryBuffer: Could not read 1 bytes from buffer.' in /Users/mponnambalam/work/eclipse/workspace/thrift0.6.1/lib/php/src/transport/TMemoryBuffer.php on line 58
> TTransportException: TMemoryBuffer: Could not read 1 bytes from buffer. in /Users/mponnambalam/work/eclipse/workspace/thrift0.6.1/lib/php/src/transport/TMemoryBuffer.php on line 58
> Call Stack:
>     0.0003     636976   1. {main}() /Users/mponnambalam/work/eclipse/workspace/TestSchema/testsimple.php:0
>     0.0041    1509944   2. TBinarySerializer::deserialize() /Users/mponnambalam/work/eclipse/workspace/TestSchema/testsimple.php:47
>     0.0041    1512248   3. Person->read() /Users/mponnambalam/work/eclipse/workspace/thrift0.6.1/lib/php/src/protocol/TBinarySerializer.php:66
>     0.0041    1512472   4. TBinaryProtocol->readFieldBegin() /Users/mponnambalam/work/eclipse/workspace/TestSchema/gen-php/simple/simple_types.php:45
>     0.0041    1512472   5. TBinaryProtocol->readByte() /Users/mponnambalam/work/eclipse/workspace/thrift0.6.1/lib/php/src/protocol/TBinaryProtocol.php:231
>     0.0041    1512520   6. TBufferedTransport->readAll() /Users/mponnambalam/work/eclipse/workspace/thrift0.6.1/lib/php/src/protocol/TBinaryProtocol.php:283
>     0.0041    1512568   7. TTransport->readAll() /Users/mponnambalam/work/eclipse/workspace/thrift0.6.1/lib/php/src/transport/TBufferedTransport.php:109
>     0.0041    1512744   8. TMemoryBuffer->read() /Users/mponnambalam/work/eclipse/workspace/thrift0.6.1/lib/php/src/transport/TTransport.php:87

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira