php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65242 AMQPExchange->bind() hangs forever if flags given
Submitted: 2013-07-11 10:14 UTC Modified: 2013-07-11 10:17 UTC
From: metamorfozis at metamorfozis dot hu Assigned:
Status: Open Package: amqp (PECL)
PHP Version: Irrelevant OS: ubuntu 12.10
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-07-11 10:14 UTC] metamorfozis at metamorfozis dot hu
Description:
------------
Hello!

Using amqp-1.0.10, on 64bit linux system (tested on different distributions),
AMQPExchange->bind() hangs forever if flags given. So it does not exit, it does 
not proceed, does not print any error, it waits forever.

We have found the solution also:

The problem is that in the bind-s definition:
amqp_exchange.c:
PHP_METHOD(amqp_exchange_class, bind)
{
[...]

int flags;

if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oss|l", 
&id, amqp_exchange_class_entry, &src_name, &src_name_len, &keyname, 
&keyname_len, &flags) == FAILURE) {
		return;
	}

[...]

The flags should be declared as long, because it is how it is used later in 
zend_parse_method_parameters.

We have tried, and it works if the int is changed to long.
The problem only occurs on 64 bit systems, on 32bit the problem doesn't comes 
up.





Test script:
---------------
Not works:

$connection->connect();
$channel=new AMQPChannel($connection);
$ex=new AMQPExchange($channel);
$ex->setName('test_exchange');
$ex->setType('topic');
$ex->declare();
print __LINE__."\n";
$ex->bind('amq.direct','test',AMQP_NOWAIT);
print __LINE__."\n";

Works:

$connection->connect();
$channel=new AMQPChannel($connection);
$ex=new AMQPExchange($channel);
$ex->setName('test_exchange');
$ex->setType('topic');
$ex->declare();
print __LINE__."\n";
$ex->bind('amq.direct','test');
print __LINE__."\n";


Expected result:
----------------
Using the examples above:

$ php -f test_bind_notworks.php 
29
31

$ php -f test_bind_notworks.php 
29
31

Actual result:
--------------
Using the examples above:

$ php -f test_bind_notworks.php 
29
^C <--- stalled forewer, needed to press CTRL-C

$ php -f test_bind_notworks.php 
29
31

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-07-11 10:17 UTC] metamorfozis at metamorfozis dot hu
In the expected/actual results it was a copy/paste error, the second file name 
was test_bind_works.php, don't get confused by that.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Nov 17 00:01:34 2019 UTC