php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59234 Segmentation fault on calling error() of a fresh worker
Submitted: 2010-05-27 05:59 UTC Modified: 2011-05-15 03:20 UTC
From: kelfe at gmx dot de Assigned: hradtke (profile)
Status: Closed Package: gearman (PECL)
PHP Version: 5.2.13 OS: Gentoo x86 and x86_64
Private report: No CVE-ID: None
 [2010-05-27 05:59 UTC] kelfe at gmx dot de
Description:
------------
fetching an error on a fresh worker produces a segmentation fault


Reproduce code:
---------------
php -r '$gmw=new GearmanWorker();echo $gmw->error();'

Expected result:
----------------
no segmentation fault

Actual result:
--------------
php -r '$gmw=new GearmanWorker();echo $gmw->error();'
Segmentation fault


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-06 12:46 UTC] jiayong dot ou at ymc dot ch
Ran into the same bug. It occurs when calling 
GearmanWorker::error() when there's no error. In that case 
gearman_worker_error() returns NULL and RETURN_STRING 
doesn't like NULLs. That issues is fixed in 
GearmanClient::error(), so 
I changed GearmanWorker::error() to check for NULL first, 
too:


--- php_gearman.c.orig	2011-01-06 18:37:07.000000000 +0100
+++ php_gearman.c	2011-01-06 18:38:48.000000000 +0100
@@ -3131,10 +3131,14 @@
 PHP_FUNCTION(gearman_worker_error) {
 	zval *zobj;
 	gearman_worker_obj *obj;
+	char  *error = NULL;
 
 	GEARMAN_ZPMP(RETURN_NULL(), "", &zobj, 
gearman_worker_ce)
-
-	RETURN_STRING((char *)gearman_worker_error(&(obj-
>worker)), 1);
+	error = (char *)gearman_worker_error(&(obj-
>worker));
+	if (error) {
+		RETURN_STRING(error, 1)
+	} 
+	RETURN_FALSE;
 }
 /* }}} */
 [2011-01-06 12:49 UTC] jiayong dot ou at ymc dot ch
Bug tracker f'd up the formatting of the patch. Here it is on 
pastebin: http://pastebin.com/UBg8xYDN
 [2011-05-15 03:20 UTC] hradtke@php.net
This bug has been fixed in SVN.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.


 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Jan 23 04:01:24 2020 UTC