Segmentation Gearman PHP failure from the command line

I am using Ubuntu Natty with PHP 5.3.5 and PECL Gearman 0.8.0 . Here is the version information:

PHP 5.3.5-1ubuntu7.3 with Suhosin-Patch (cli) (built: Oct 13 2011 22:20:48) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies with the ionCube PHP Loader v4.0.10, Copyright (c) 2002-2011, by ionCube Ltd., and with Zend Guard Loader v3.3, Copyright (c) 1998-2010, by Zend Technologies with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH 

I get a segmentation error when I try to start the Gearman client through the command line (I already have my worker).

Here is what I get on the command line:

 root@Local :~/sandbox# php php_gearman_client.php Sending job Segmentation fault 

Here is my working code:

 <?php echo "Starting\n"; # Create our worker object. $gmworker= new GearmanWorker(); # Add default server (localhost). $gmworker->addServer(); # Register function "reverse" with the server. Change the worker function to # "reverse_fn_fast" for a faster worker with no output. $gmworker->addFunction("reverse", "reverse_fn"); print "Waiting for job...\n"; while($gmworker->work()) { if ($gmworker->returnCode() != GEARMAN_SUCCESS) { echo "return_code: " . $gmworker->returnCode() . "\n"; break; } } function reverse_fn($job) { echo "Received job: " . $job->handle() . "\n"; $workload = $job->workload(); $workload_size = $job->workloadSize(); echo "Workload: $workload ($workload_size)\n"; # This status loop is not needed, just showing how it works for ($x= 0; $x < $workload_size; $x++) { echo "Sending status: " . ($x + 1) . "/$workload_size complete\n"; $job->sendStatus($x, $workload_size); sleep(1); } $result= strrev($workload); echo "Result: $result\n"; # Return what we want to send back to the client. return $result; } # A much simpler and less verbose version of the above function would be: function reverse_fn_fast($job) { return strrev($job->workload()); } ?> 

And here is my client code:

 <?php # Create our client object. $gmclient= new GearmanClient(); # Add default server (localhost). $gmclient->addServer(); echo "Sending job\n"; # Send reverse job do { $result = $gmclient->do("reverse", "Hello!"); # Check for various return packets and errors. switch($gmclient->returnCode()) { case GEARMAN_WORK_DATA: echo "Data: $result\n"; break; case GEARMAN_WORK_STATUS: list($numerator, $denominator)= $gmclient->doStatus(); echo "Status: $numerator/$denominator complete\n"; break; case GEARMAN_WORK_FAIL: echo "Failed\n"; exit; case GEARMAN_SUCCESS: break; default: echo "RET: " . $gmclient->returnCode() . "\n"; exit; } } while($gmclient->returnCode() != GEARMAN_SUCCESS); ?> 

EDIT

It seems that the segmentation error was caused by Imagick. So I decided to do the following.

  • Remove imagick dpkg --purge --force-all php5-imagick . I installed this when I configured PHP
  • Restart PHP (this may vary depending on how you installed php)
  • Reboot the Gearman job server /etc/init.d/gearman-job-server stop && /etc/init.d/gearman-job-server

Everything seems to be working fine.

+4
source share
2 answers

since this is a segmentation error, which means that something is wrong with your installation. Run dmesg to find out the details, there may be a problem with some php extension that might be disabled.

+2
source

I just had this problem. This is the soution that I took (until completely ), and the steps for observing the error.

Step 1.

The launch of Gearman Worker led to:

Segmentation error

Step 2

Run dmesg from the shell, I noticed that it was shown.

[2423402.716386] php [21232]: segfault at 30 ip b66d0321 sp bfc704c0 error 6 in libuuid.so.1.3.0 [b66cf000 + 3000]

Step 3

Googled for libuuid.so, and it became apparent that Imagick uses uuid_create() for Image UUID.

http://usrportage.de/archives/922-PHP-segfaulting-with-pecluuid-and-peclimagick.html

Step 4. (Solution)

I ensured that the Imagick extension is initialized with the last of all my PHP extensions. So before I was on the first line of my

/etc/php5/conf.d/extensions.ini file imagick.so

Instead, I created a file called imagick.ini , and the contents of this file were

imagick.so

Since extensions are loaded in alphabetical order (and if you run your Workline through the command line), loading imagix last ensures that all dependent extensions are loaded first. In this case, libuuid.

+2
source

Source: https://habr.com/ru/post/1383234/


All Articles