|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62628 Exception thrown in consume will lock PHP
Submitted: 2012-07-21 06:25 UTC Modified: 2012-08-26 03:03 UTC
Avg. Score:4.3 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:1 (33.3%)
From: cg-php at charlesgentry dot com Assigned: pdezwart (profile)
Status: Closed Package: amqp (PECL)
PHP Version: 5.3.15 OS: Ubuntu 12.04LTE
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: cg-php at charlesgentry dot com
New email:
PHP Version: OS:


 [2012-07-21 06:25 UTC] cg-php at charlesgentry dot com
If the code in the callback of the consume function throws an exception, PHP will 
lock up. This is caused by the amqp_consume ignoring exceptions and continuing to 
try to call the function.

This happens with both 1.0.3 and 1.0.4

Test script:
$cnn = new AMQPConnection();  $cnn->connect();
$ch  = new AMQPChannel($cnn);
$ex  = new AMQPExchange($ch);  $ex->setName('exchange-' . time()); $ex->setType(AMQP_EX_TYPE_FANOUT); $ex->declare();
$q   = new AMQPQueue($ch);    $q->setName('queue-' . time());     $q->declare();
$q->bind($ex->getName(), 'routing.*');
$ex->publish('message1', 'routing.1'); $ex->publish('message2', 'routing.2');
$count = 0;
function consumeThings($message, $queue) {
        global $count; $count++;
        echo $message->getBody() . "-" . $message->getRoutingKey() . "\n";
        if ($count == 2) {
                global $ex,$q;
                $ex->delete(); $q->delete();
                throw new Exception( "Dead" );
        return true;
try{ $q->consume("consumeThings"); }catch( Exception $e ){ print $e->getMessage(); }
/*--EXPECT-- message1-routing.1 message2-routing.2 Dead */

Expected result:

Actual result:

and then hang.


ampq_queue-patch.c (last revision 2012-07-21 06:27 UTC by cg-php at charlesgentry dot com)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-08-23 11:07 UTC] mwilliams at webgains dot com
When will this be fixed? I am having the same issue.
 [2012-08-26 03:03 UTC]
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at

 For Windows:
Thank you for the report, and for helping us make PHP better.

Will be part of 1.0.5 release. Thanks!
 [2012-08-26 03:03 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: pdezwart
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Sep 22 11:03:37 2021 UTC