php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60764 Enabling Non-Blocking Mode causes asseration
Submitted: 2012-01-16 01:55 UTC Modified: 2013-02-18 00:35 UTC
Votes:69
Avg. Score:4.7 ± 0.6
Reproduced:56 of 57 (98.2%)
Same Version:19 (33.9%)
Same OS:12 (21.4%)
From: datasage at theworldisgrey dot com Assigned: hradtke (profile)
Status: No Feedback Package: gearman (PECL)
PHP Version: 5.3.9 OS: Amazon Linux
Private report: No CVE-ID: None
 [2012-01-16 01:55 UTC] datasage at theworldisgrey dot com
Description:
------------
Using non-blocking mode does help manage multiple workers and be able to use 
signals to gracefully handle shutdown of those workers.

However enabling non blocking mode results in the following assertion:

libgearman/universal.cc:519: bool gearman_request_option(gearman_universal_st&, 
gearman_string_t&): Assertion `con->recv_state == GEARMAN_CON_RECV_UNIVERSAL_NONE' 
failed.

Gearman php module 1.0.1 is installed with libgearman 0.27. I also tried 0.26, but 
that has another assertion which seems to be fixed in 0.27.

This could be an upstream issue with libgearman instead of the php extension. I'm 
going to file a report there as well.

Test script:
---------------
I am using this: https://github.com/brianlmoon/GearmanManager

Disabling this line: $thisWorker->addOptions(GEARMAN_WORKER_NON_BLOCKING); fixes the issue, although its preferable to have that enabled.

Expected result:
----------------
No Error

Actual result:
--------------
libgearman/universal.cc:519: bool gearman_request_option(gearman_universal_st&, 
gearman_string_t&):    Assertion `con->recv_state == 
GEARMAN_CON_RECV_UNIVERSAL_NONE' failed.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-01-17 21:59 UTC] datasage at theworldisgrey dot com
This does look like an issue with the php extension, I downgraded to 0.8.1 and 
blocking mode no longer causes the assertion.
 [2012-01-22 19:45 UTC] rasmus@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: hradtke
 [2012-07-04 03:10 UTC] c2h5oh at poczta dot fm
Same problem: Ubuntu 12.4 + PHP 5.3.13 + latest pecl and gearman 0.33
 [2012-07-12 12:08 UTC] michel dot hartmann at mayflower dot de
Same problem here on:
- PHP 5.3.14-1~dotdeb.0 with Suhosin-Patch (cli) (built: Jun 21 2012 00:51:58)
- gearman-extension 1.0.2
- libgearman 0.33-2

Test script:
---------------
<?php

$worker= new GearmanWorker();
$worker->addOptions(GEARMAN_WORKER_NON_BLOCKING);
$worker->addServer();
$worker->addFunction('reverse', 'reverse_fn');

$worker->work();
printf("Return Code: %d\n", $worker->returnCode());
$worker->work();

function reverse_fn($job)
{
    return strrev($job->workload());
}

Expected result:
----------------
No Error

Actual result:
--------------
Return Code: 1
php: libgearman/universal.cc:616: bool 
gearman_request_option(gearman_universal_st&, gearman_string_t&): Assertion 
`con->recv_state == GEARMAN_CON_RECV_UNIVERSAL_NONE' failed.
Aborted
 [2012-07-16 22:05 UTC] bob at ifixit dot com
Same problem here.

CentOS 5
PHP 5.4.0
Gearman 0.33
Gearman Extension 1.0.2

Any progress on this? It's been sitting open for months...
 [2012-07-16 22:09 UTC] mgiglesias at gmail dot com
Same issue here.

* Arch Linux (Kernel 3.4.4 x86_64)
* Gearman 0.33
* Gearman PECL 1.0.2
* PHP 5.4.4
 [2012-08-01 20:49 UTC] phpowers at gmail dot com
Same behavior here

PHP 5.3.14-pl0-gentoo (cli) (built: Jul 23 2012 17:09:17)
 [2012-08-06 04:46 UTC] hradtke@php.net
-Status: Assigned +Status: Feedback
 [2012-08-06 04:46 UTC] hradtke@php.net
I ran the provided test script and cannot recreate the bug. The expected result 
from michel.hartmann's patch is a return code of 35 (GEARMAN_NO_JOBS) in most 
cases. This is to be expected.

Tested on:
CentOS 6
PHP trunk
Gearman 0.33
Gearman Extension 1.0.3
 [2012-08-23 18:51 UTC] me at re-becca dot org
The provided test script gives me the following:

Return Code: 1
Assertion failed: (con->recv_state == GEARMAN_CON_RECV_UNIVERSAL_NONE), function 
gearman_request_option, file libgearman/universal.cc, line 553.
Abort trap

MacOS
PHP 5.3.9
PECL gearman 1.0.3
libgearman 0.34
 [2012-10-21 00:43 UTC] gmsalex at gmail dot com
Received same problem with pecl-gearman-1.0.2,pecl-gearman-1.0.3,pecl-gearman-1.1.0.

Then I switched to pecl-gearman-0.8.3 and fortunately problem disappeared.
 [2012-11-21 16:07 UTC] alexis dot peter at cargomedia dot ch
I am having the same issues.
Ran the testscript on two machines to reproduce the bug.

Ubuntu (3.2.0-33-generic) 
libgearman version => 1.1.2
pecl-gearman version => 1.1.0

Debian (2.6.32-5-amd64)
libgearman version => 1.1.2
pecl-gearman version => 1.1.0

Return Code: 1
php: libgearman/universal.cc:486: gearman_return_t connection_loop(gearman_universal_st&, const gearman_packet_st&, Check&): Assertion `packet_ptr == &con->_packet' failed.
Aborted (core dumped)
 [2013-01-08 11:22 UTC] gdanskamir at gmail dot com
Same problem.

Use the code with php.net http://docs.php.net/manual/en/gearmanworker.wait.php

OS: Linux  2.6.32_1-1-0-0 #1 SMP Wed Apr 6 18:07:00 CST 2011 x86_64
PHP: 5.2.14
pecl/gearman: 1.1.0
gearman: 1.1.3

php: libgearman/universal.cc:486: gearman_return_t 
connection_loop(gearman_universal_st&, const gearman_packet_st&, Check&): 
Assertion `packet_ptr == &con->_packet' failed.
Aborted


(gdb) bt
#0  0x000000302af2e2ed in raise () from /lib64/tls/libc.so.6
#1  0x000000302af2fa3e in abort () from /lib64/tls/libc.so.6
#2  0x000000302af27ba1 in __assert_fail () from /lib64/tls/libc.so.6
#3  0x00007fe3583e82fb in connection_loop (universal=@0xe44350, 
message=@0x7fffb30c4380, check=@0x7fffb30c4360) at libgearman/universal.cc:497
#4  0x00007fe3583e866a in gearman_request_option (universal=@0xe44350, 
option=Variable "option" is not available.
) at libgearman/universal.cc:576
#5  0x00007fe3583eaae8 in gearman_worker_set_server_option 
(worker_shell=Variable "worker_shell" is not available.
) at ./libgearman-1.0/interface/worker.h:53
#6  0x00007fe3583dc883 in zif_gearman_worker_work (ht=Variable "ht" is not 
available.
) at /home/work/software/gearman-1.1.0/php_gearman.c:3646
#7  0x000000000073483e in zend_do_fcall_common_helper_SPEC 
(execute_data=0x7fffb30c4ee0)
    at /home/work/hcthirdparty/download/php_5-2-14-100_PD_BL/php-
5.2.14/Zend/zend_vm_execute.h:200
#8  0x0000000000733e51 in execute (op_array=0x7fe35b354220)
    at /home/work/hcthirdparty/download/php_5-2-14-100_PD_BL/php-
5.2.14/Zend/zend_vm_execute.h:92
#9  0x0000000000714f14 in zend_execute_scripts (type=8, retval=0x0, 
file_count=3)
    at /home/work/hcthirdparty/download/php_5-2-14-100_PD_BL/php-
5.2.14/Zend/zend.c:1134
#10 0x00000000006d1e2d in php_execute_script (primary_file=0x7fffb30c7660)
    at /home/work/hcthirdparty/download/php_5-2-14-100_PD_BL/php-
5.2.14/main/main.c:2036
#11 0x00000000007a6263 in main (argc=2, argv=0x7fffb30c77c8)
    at /home/work/hcthirdparty/download/php_5-2-14-100_PD_BL/php-
5.2.14/sapi/cli/php_cli.c:1165
 [2013-01-10 17:16 UTC] keyur_govande at yahoo dot com
Can you try with the pecl release 1.1.1?

Thanks!
 [2013-02-18 00:35 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Nov 26 02:01:32 2024 UTC