When performing a specific action* in a Drupal 7 project, I get the following error in /var/log/apache2/error.log:
[Fri Jun 26 09:53:55.307644 2015] [core:notice] [pid 1553] AH00051: child pid 9998 exit signal Segmentation fault (11), possible coredump in /etc/apache2
Except that when using the step by step function of Xdebug, it doesn't crash.
And when using xdebug.auto_trace=ON, it doesn't crash either.
What could cause a segmentation fault in PHP, except when using Xdebug?
*: The error occurs when sending an email, but only when the recipient is the currently logged in user.
By putting log messages in the code, I've been able to determine that the crash occurs when autoloading the MailMIME class.
In includes/bootstrap.inc, in the _registry_check_code function, if I put the following code:
if($type == 'class' && $name == 'MailMIME')
{
file_put_contents('/tmp/log.txt', "DEBUG 01\n", FILE_APPEND);
}
before line 3147, which is:
$file = Database::getConnection('default', 'default')->query("SELECT filename FROM {registry} WHERE name = :name AND type = :type", array(
':name' => $name,
':type' => $type,
))
->fetchField();
then, I can see "DEBUG 01" in my log file, and it crashes.
However, if I put the same code after the lines 3147 to 3151, it stops crashing...
EDIT: I am able to reproduce the bug on my Ubuntu 14.04 machine with PHP 5.5, but I can't reproduce it on a Windows machine with PHP 5.6.
Related
PLEASE IGNORE THIS QUESITON - I FOUND THAT THE PROBLEM DESCRIBED HERE IS NOT THE REAL PROBLEM.
thanks to those who tried to help.
The problem is gmagick specific. Not a general php issue.
I have this simple code on PHP Version 5.6.40-6+ubuntu18.04.1+deb.sury.org+3
<?php
header("Content-type: image/png");
$base_image = new Gmagick();
$base_image->newImage(3, 3, "#555555");
$base_image->setImageFormat('png');
$x = $base_image->getImage();
echo $x;
?>
It works well (put out a 3x3 image) on ubuntu 16 php 5.6 server.
I've created a new Ubuntu 18.04 server from scratch with the same stack (details below) but it crashes on the echo statement.
The error log shows: [Thu Apr 11 11:35:48.110542 2019] [core:notice]
[pid 9875] AH00051: child pid 10298 exit signal Segmentation fault
(11), possible coredump in /etc/apache2
What can cause such failure in the echo of a binary string representing an image?
See stack details here
https://www.awesomescreenshot.com/image/3968080/0606779cd806f2d6a6e02828dd643dfd
I am referring to this documentation.
so var_dump($x); should give you a proper solution as it's object not string.
Returns a new Gmagick object with the current image sequence.
It's an Imagick object. You can convert it to string like:
$x::getImageBlob()
see in: https://www.php.net/manual/en/imagick.getimageblob.php
I have a Magento 1.9 shop on a Ubuntu server - it has run without any problems for about a year. When I now open /cron.php in my Chrome browser, I get the following error: ERR_EMPTY_RESPONSE
I have looked into my apache errors log. It says:
[core:notice] [pid 1992] AH00051: child pid 2083 exit signal
Segmentation fault (11), possible coredump in /etc/apache2
... everytime when I try to load the cron.php script.
My syslog shows the following error:
kernel: [ 774.131560] php[2406]: segfault at 7ffc036eceb8 ip
00007f7c1fd7a55a sp 00007ffc036eceb0 error 6 in
libpcre.so.3.13.1[7f7c1fd67000+3d000]
I've found out, that the error occurs at a recursive function in my php script. The function looks quite ok to me.
It turned out that the PHP script had a recurive function with an infinite loop under certain conditions. I would have thought this would just lead to a script timeout. Maybe someone can explain in detail...
I'm currently experimenting with a PHP plugin called Mosquitto PHP (https://github.com/mgdm/Mosquitto-PHP/). I've got it all installed right, and under 'php -m' it seems to show up properly.
I'm using a small test code to see if it in it's basic form works:
<?php
$c = new Mosquitto\Client;
$c->onConnect(function() use ($c) {
$c->publish('mgdm/test', 'Hello', 2);
});
$c->connect('test.mosquitto.org');
for ($i = 0; $i < 100; $i++) {
// Loop around to permit the library to do its work
$c->loop(1);
}
echo "Finished\n";
?>
And that seemed to return "Finished" in my browser. So, I decided to up my game, and add a TLS connection, as documented, to this:
<?php
$c = new Mosquitto\Client;
$c->onConnect(function() use ($c) {
$c->publish('mgdm/test', 'Hello', 2);
});
$c->setTlsCertificates('mosquitto.org.crt');
$c->connect('test.mosquitto.org', '8883');
for ($i = 0; $i < 100; $i++) {
$c->loop(1);
}
echo "Finished\n";
?>
I got the certificate and I've made sure apache2 could read it and set the ownership subsequently to apache2. This turned out to give me the 500 internal sever error in my browser.
-rwsrwsrwt 1 www-data www-data 279 Jun 5 04:12 test.php
-rwxrwxrwx 1 www-data www-data 1078 Jun 30 2012 mosquitto.org.crt
Out of curiousity, I navigated to the script in shell and ran it with:
sudo php test.php
This resulting in a printed "Finished" in my ssh, and it sent the message through the broker.
This made me think it's an odd sort of permission error. Investigating further, I found these in my logs:
My apache2 log:
mod_fcgid: process /var/www/php-fcgi-scripts/web1/.php-fcgi-starter(20614) exit(communication error), get unexpected signal 11
mog_fcgid installed is:
libapache2-mod-fcgid 1:2.3.9-1+b1 amd64 FastCGI interface module for Apache 2
and it is, same with suexec is enabled as far as I can tell.:
Module fcgid already enabled
Module suexec already enabled
In a small twist of events, I changed the .php to .fcgi and gave it +x permission, and now the messages goes through the broker, but still it gives a 500 error in my browser.
suexec log shows:
[2016-06-07 14:05:58]: uid: (5004/web1) gid: (5005/client0) cmd: test.fcgi
and in my ispconfig log it shows:
[Tue Jun 07 14:08:25.567945 2016] [fcgid:warn] [pid 27861] (104)Connection reset by peer: [client 93.135.88.60:49328] mod_fcgid: error reading data from FastCGI server
[Tue Jun 07 14:08:25.568016 2016] [core:error] [pid 27861] [client 93.135.88.60:49328] End of script output before headers: test.fcgi
I'm totally lost for words here.. I need help!!
Try to increase the memory for php-fcgi (by default for cli memory_limit=-1).
I think this case should resolve your problem.
UPDATE
I have installed mosquitto (from php7 branch) and try it (run test.php from repository examples. php 7.0.7). And i have segfault to
segfault at 8 ip 00005574a41c753f sp 00007ffc2dc85da0 error 6 in php7.0[5574a3f80000+391000]
It seems that this is extension bug.
You can try to debug this segfault (https://bugs.php.net/bugs-generating-backtrace.php) and send report to extension developers.
I just tried to install the PHP SDK on my Ubuntu 14.04.
I started with the C SDK, then isntalled the PHP SDK with pecl.
Everything works fine, i got no errors, a couchbase.so is installed in /usr/lib/php55/…
But when i add a
extension=couchbase.so to my php.ini everything broke, i can't display any php page.
I checked the logs and see:
[Wed Jan 20 11:36:39.872396 2016] [core:notice] [pid 4265] AH00052: child pid 4298 exit signal Segmentation fault (11)
Looks bad uh ?
Any tips to make this works?
I mentioned this to the project maintainer this morning and his hypothesis is that PHP may have had a change in 5.5 that has lead to the breakage as he's seen this sort of thing in the past. Perhaps you can try an older version or get more info per the comment on backtraces above.
I have a class file which has some buggy code e.g
else{
$stp->Object($a);
$abbr = $a->abbr;
}
asdf
}
My understanding is that php should properly display an error message e.g saying sth that "asdf" is not a class or constant etc . But as I see this peice of code crashes the server with segmentation fault , as my error log file says:
[Fri Mar 08 17:21:37 2013] [notice] child pid 8615 exit signal Segmentation fault (11)
Is it possible to configure php/apache to properly handle these errors ?
Why php is failing to report the error some understandable way . I only see "The connection was reset"
message in browser.
Specification:
XAMPP (php 5.3.1)
MAC OS 10.6
Xdebuger installed
Apparently something is going wrong into Apache, so it can't be properly displayed because the Apache child exit.
I had some similar error once because the PHP error made a redirection to a PHP error file (ex: ErrorDocument 500), which contained the same error, so it redirect to the PHP error page and so on... making a redirection loop.
Apache kill itself to avoid the machine to go down.
You have to diagnose what is making Apache die.
To do this, install "strace", eg. on debian :
apt-get install strace
Then stop your Apache, and start it through strace :
strace -f /usr/sbin/apache2ctl
Reproduce your problem until your Apache child crash, and try to look into the strace log to find out what happened.
Hope this helped.