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

ruslan.usifov edited comment on THRIFT-1067 at 2/20/11 9:35 AM:
----------------------------------------------------------------

I explain some of them:

2). Hung when work throw thrift framed transport
In PHPOutputTransport destructor you make flush(), but in 
PHP_FUNCTION(thrift_protocol_write_binary) you make flash too at the end: 
transport.flush(), in framed transport this call hung

3). Memleak in protocol_writeMessageBegin
In this function you allocate 3 function agrs (MAKE_STD_ZVAL), but doesn't free 
them with zval_ptr_dtor. On very long executed scripts this results as 

Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 
30084 bytes)

How fast you got this error, depends on your memory_limit config param in 
php.ini

4). Hung when server close connection, and when php code try reuse same 
connection
To reproduce:

{code}
<?php
define("LIBPATH", "lib/");

require_once("thrift/Thrift.php");
require_once("thrift/transport/TSocket.php");
require_once("thrift/transport/TFramedTransport.php");
require_once("thrift/protocol/TBinaryProtocol.php");

require_once('Log.php');
require_once('Log/file.php');

require_once(LIBPATH."cassandra/Cassandra.php");
require_once(LIBPATH."cassandra/cassandra_types.php");

$transport = new TFramedTransport(new TSocket("localhost", 9160));
$protocol  = new TBinaryProtocolAccelerated($transport);

$client = new CassandraClient($protocol);
$transport->open();

$client->set_keyspace("test");

$l_supercolumn = new cassandra_SuperColumn(array("name" => '12', "columns" => 
NULL));
$l_c_or_sc = new cassandra_ColumnOrSuperColumn(array("super_column" => 
$l_supercolumn));
$l_mutation = new cassandra_Mutation(array("column_or_supercolumn" => 
$l_c_or_sc));

for($i=0; $i < 10; $i++)
{
        try
        {
                $client->batch_mutate(array('1' => array('test' => 
array($l_mutation))), cassandra_ConsistencyLevel::QUORUM);
        }
        catch(Exception $e)
        {
                print $e;
                print "\n\n";
        };
};

sleep(30);
?>
{code}


This code when fist time got to batch_mutate, will throw TApplication 
exception, second attempt will hung in TSocket::readAll, because fread will 
always return empty data

5). Impossible pass really long values on 32 bit platforms

Try to pass something like this: 4294967296 on 32 bit platform  and look what 
you get on server. Result will surprise you



      was (Author: tantra):
    I explain some of them:

2). Hung when work throw thrift framed transport
In PHPOutputTransport destructor you make flush(), but in 
PHP_FUNCTION(thrift_protocol_write_binary) you make flash too at the end: 
transport.flush(), in framed transport this call hung

3). Memleak in protocol_writeMessageBegin
In this function you allocate 3 function agrs (MAKE_STD_ZVAL), but doesn't free 
them with zval_ptr_dtor. On very long executed scripts this results as 

Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 
30084 bytes)

How fast you got this error, depends on your memory_limit config param in php

4). Hung when server close connection, and when php code try reuse same 
connection
To reproduce:

{code}
<?php
define("LIBPATH", "lib/");

require_once("thrift/Thrift.php");
require_once("thrift/transport/TSocket.php");
require_once("thrift/transport/TFramedTransport.php");
require_once("thrift/protocol/TBinaryProtocol.php");

require_once('Log.php');
require_once('Log/file.php');

require_once(LIBPATH."cassandra/Cassandra.php");
require_once(LIBPATH."cassandra/cassandra_types.php");

$transport = new TFramedTransport(new TSocket("localhost", 9160));
$protocol  = new TBinaryProtocolAccelerated($transport);

$client = new CassandraClient($protocol);
$transport->open();

$client->set_keyspace("test");

$l_supercolumn = new cassandra_SuperColumn(array("name" => '12', "columns" => 
NULL));
$l_c_or_sc = new cassandra_ColumnOrSuperColumn(array("super_column" => 
$l_supercolumn));
$l_mutation = new cassandra_Mutation(array("column_or_supercolumn" => 
$l_c_or_sc));

for($i=0; $i < 10; $i++)
{
        try
        {
                $client->batch_mutate(array('1' => array('test' => 
array($l_mutation))), cassandra_ConsistencyLevel::QUORUM);
        }
        catch(Exception $e)
        {
                print $e;
                print "\n\n";
        };
};

sleep(30);
?>
{code}


This code when fist time got to batch_mutate, will throw TApplication 
exception, second attempt will hung in TSocket::readAll, because fread will 
always return empty data

5). Impossible pass really long values on 32 bit platforms

Try to pass something like this: 4294967296 on 32 bit platform  and look what 
you get on server. Result will surprise you


  
> Tons of bugs in php implementation
> ----------------------------------
>
>                 Key: THRIFT-1067
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1067
>             Project: Thrift
>          Issue Type: Bug
>          Components: PHP - Library
>    Affects Versions: 0.6
>            Reporter: ruslan.usifov
>         Attachments: php20110219.patch
>
>
> PHP version of thrift hold many bugs:
> 1). Incorrect work with ZTS
> 2). Hung when work throw thrift framed transport
> 3). Memleak in protocol_writeMessageBegin
> 4). Hung when server close connection, and when php code try reuse same 
> connection
> 5). Impossible pass really long values on 32 bit platforms

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

        

Reply via email to