How to generate coredump in CentOS (php-fpm) - php

I have this setting in www.conf (php-fpm):
rlimit_core = unlimited
Also I have this command:
ulimit -c unlimited
and my setting is:
# cat /proc/sys/kernel/core_pattern
/tmp/core-%e-%s-%u-%g-%p-%t
# cat /proc/sys/kernel/core_uses_pid
1
In error.log I have:
child 26279 exited on signal 11 (SIGSEGV - core dumped) after 522.834434 seconds from start
It tells me that a core was dumped, but I didn't find coredump in /tmp
How can I generate coredump file and find it?

I find it in /tmp/systemd-private-bc833f133c6449c6bb1ebe9850277d66-php-fpm.service-zKMT4i/tmp/

Related

HHVM RepoMode Segmentation Fault

Specs:
Ubunutu 16.04.1 Server
nginx 1.10
HHVM 3.17.0
I am attempting to gather a list of files, and run them through the hhvm compiler to utilize repo mode, with the following code:
#!/bin/bash
if [ "$(whoami)" != "root" ]; then
echo "Only root can do this.";
exit 1;
else
if [ $# -eq 0 ]; then
echo "Please pass the account name to enable this for"
exit 1;
else
#Get a list of files
FLIST=$(find /home/$1/www/ -type f -name '*.php');
for F in $FLIST
do
if [ -f $F ]; then
echo "Adding; $F";
echo $F >> $1-list.txt;
fi;
done;
hhvm --hphp -t hhbc -v AllVolatile=false -v WholeProgram=false --input-list $1-list.txt;
sleep 1;
rm -f $1-list.txt;
fi;
fi;
Upon running it on my server, I am presented with:
running hphp...
creating temporary directory /tmp/hphp_cFPMUQ ...
parsing inputs...
Unable to stat file /home/kpirnie/www/wp-content/PHPMailer/vendor/autoload.php
Unable to stat file /home/kpirnie/www/wp-content/PHPMailer/test/vendor/autoload.php
Unable to stat file /home/kpirnie/www/wp-content/PHPMailer/test/testbootstrap.php
Unable to stat file /home/kpirnie/www/wp-content/plugins/cloudflare/vendor/cloudflare/cf-ip-rewrite/vendor/autoload.php
Unable to stat file /home/kpirnie/www/wp-content/plugins/cloudflare/vendor/guzzle/guzzle/phing/tasks/phing/Task.php
Unable to stat file /home/kpirnie/www/wp-content/plugins/cloudflare/vendor/guzzle/guzzle/phar:/guzzle.phar/vendor/symfony/class-loader/Symfony/Component/ClassLoader/UniversalClassLoader.php
Unable to stat file /home/kpirnie/www/wp-content/plugins/cloudflare/vendor/guzzle/guzzle/phing/tasks/PEAR/PackageFileManager2.php
Unable to stat file /home/kpirnie/www/wp-content/plugins/cloudflare/vendor/guzzle/guzzle/phing/tasks/PEAR/PackageFileManager/File.php
Unable to stat file /home/kpirnie/www/wp-content/plugins/cloudflare/vendor/guzzle/guzzle/phing/tasks/PEAR/Packager.php
Unable to stat file /home/kpirnie/www/wp-content/plugins/cloudflare/vendor/guzzle/guzzle/phing/tasks/phing/tasks/ext/git/GitBaseTask.php
Unable to stat file /home/kpirnie/www/wp-content/plugins/cloudflare/vendor/sebastian/comparator/vendor/autoload.php
Unable to stat file /home/kpirnie/www/wp-content/plugins/wordpress-seo/vendor/composer/autoload_static.php
parsing inputs took 0'01" (1425127 us) wall time
pre-optimizing...
Core dumped: Segmentation fault
Stack trace in /tmp/stacktrace.31028.log
hphp failed
running hphp took 0'02" (2216979 us) wall time
And I can verify that the files that are Unable to stat indeed do not exist.
Stacktrace shows what looks like a memory dump (I assume) due to the segmentation fault.
How can I accomplish true Repo Mode? skip the missing files? but how?
If nothing in your source is referencing those files as you say, then try placing empty files in those places.
However, it is likely that you are referencing these files somewhere by means of a path that has included them. I suspect this is an HHVM issue and you should file your failing test-case here.

freebsd 9.1 apache-mpm php5 child segmentation fault

I've got such problem:
When I run script which uses pthreads extension, PHP crushes with this errors:
[notice] child pid 44688 exit signal Segmentation fault (11)
[notice] child pid 44689 exit signal Segmentation fault (11)
I have installed apache22-worker-mpm port, php5.4.16 with pthreads 0.44
Also command
ps -U www
provides such result:
PID TT STAT TIME COMMAND
44687 ?? TX 0:00:00 /usr/local/sbin/httpd -k restart
44688 ?? S 0:00:00 /usr/local/sbin/httpd -k restart
44689 ?? Z 0:00:00 <defunct>
44690 ?? S 0:00:00 /usr/local/sbin/httpd -k restart
Restarting apache - does nothing.
What can I do to fix this?
Thanks!
PS: on my Windows machine - all works fine, so problem isn't in php code.
The first step in investigating crashes is to obtain the stack from the core-dump.
Obtaining core-dump of Apache may be tricky -- because they are often disabled by default. But it can be done.
Now, the fact that it works on Windows is not, actually, proof, that it is not the php-code -- whatever the problem is, it may be triggered by the "just right" sort of racing between threads. The OS, the number of CPUs, and other factors all affect the results of a race...
And finally, are you sure, you are using thread-safe (zts) version of PHP itself?

PHP fopen() fails on files even with wide-open permissions

I'm currently migrating my LAMP from my Windows Server to a VPS running Debian 6. Most everything is working, however, one of the PHP scripts was failing to write to its configured log file. I could not determine why, so I wrote a new, simple, contrived PHP script to test the problem.
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
echo exec('whoami');
$log = fopen('/var/log/apache2/writetest/writetest.log', 'a');
if ($log != NULL)
{
fflush($log);
fclose($log);
$log = NULL;
}
?>
However, it fails with the result:
www-data Warning: fopen(/var/log/apache2/writetest/writetest.log): failed to open stream: Permission denied in /var/www/_admin/phpwritetest.php on line 5
While I would never do it normally, to help diagnose, I set /var/log/apache2/writetest/writetest.log to chmod 777.
Both the directory and the file are owned by www-data:www-data.
The file was created with touch.
I ran strace to verify which process was performing the open:
[pid 21931] lstat("/var/log/apache2/writetest/writetest.log", 0x7fff81677d30) = -1 EACCES (Permission denied)
[pid 21931] lstat("/var/log/apache2/writetest", 0x7fff81677b90) = -1 EACCES (Permission denied)
[pid 21931] open("/var/log/apache2/writetest/writetest.log", O_RDWR|O_CREAT|O_TRUNC, 0666) = -1 EACCES (Permission denied)
I checked and pid 21931 was indeed one of the apache2 child processes running under www-data. As you can see, I also included echo exec('whoami'); in the script which confirmed the script was being run by www-data.
Other notes:
PHP is not running in safe mode
PHP open_basedir is not set
Version info: Apache/2.2.16 (Debian) PHP/5.3.3-7+squeeze3 with Suhosin-Patch mod_ssl/2.2.16 OpenSSL/0.9.8o
uname -a: 2.6.32-238.19.1.el5.028stab092.2 #1 SMP Thu Jul 21 19:23:22 MSD 2011 x86_64 GNU/Linux
This is on a VPS running under OpenVZ
ls -l (file): -rwxrwxrwx 1 www-data www-data 0 Sep 8 18:13 writetest.log
ls -l (directory): drwxr-xr-x 2 www-data www-data 4096 Sep 8 18:13 writetest
Apache2's parent process runs under root, and the child processes under www-data
selinux is not installed (thanks to Fabio for reminding me to mention this)
I have restarted apache many times and rebooted the server as well
Remember that in order to reach a file, ALL parent directories must be readable by www-data. You strace output seems to indicate that even accessing /var/log/apache2/writetest is failing. Make sure that www-data has permissions on the following directories:
/ (r-x)
/var (r-x)
/var/log (r-x)
/var/log/apache2 (r-x)
/var/log/apache2/writetest (rwx)
/var/log/apache2/writetest/writetest.log (rw-)
Does the php file doing the writing have proper permissions set? Try changing those to see if that's the issue.
Could be a SELinux issue, even if Debian doesn't ship it in the default installation your provider could have enabled it. Look for messages in /var/log with
grep -i selinux /var/log/{syslog,messages}
If that's the cause and you need to disable it, here are instructions: look for file /etc/selinux/config, here it's default content. Change SELINUX directive to disabled and reboot the system.
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted

Apache LOG: child pid xxxx exit signal Segmentation fault (11)

Apache + PHP + Mysql + Linux
[notice] child pid 23145 exit signal Segmentation fault (11), possible coredump in /tmp
But nothing found under /tmp
How can i find the error?
Endless loop of the function in PHP code caused this error.
Check whether your PHP-FPM and PHP versions match. Make sure there is a (correct) PHP-FPM configuration corresponding to your PHP and PHP-FPM version, respectively.
PHP-FPM (config in /etc/php/7.0/fpm) and PHP versions may have gotten out of sync while updating. Updated PHP (/etc/php/7.3/) may cause apache child segfaults because of missing PHP-FPM configuration in /etc/php/7.3/.
See also “[notice] child pid XXXX exit signal Segmentation fault (11)” in apache error.log .

CoreDumpDirectory isn't working on ubuntu; getting segmentation fault with php

I'm trying to solve a segmentation fault. This message appears in my apache-error.log:
[notice] child pid 3979 exit signal
Segmentation fault (11)
I've tried disabling some apache and php modules but I'm still getting the same error.
I've also tried putting this in apache2.conf:
CoreDumpDirectory /tmp/apache2-gdb-dump
and then chmod 777, chown www-data... so that the server can write.
I can see no core-dump files to give me a hint on the error.
Does anybody have an idea why CoreDumpDirectory isn't working on Ubuntu?
answers: $ ulimit -a
core file size
(blocks, -c) unlimited data seg size
(kbytes, -d) unlimited scheduling
priority (-e) 0 file size
(blocks, -f) unlimited pending signals
(-i) 15863 max locked memory
(kbytes, -l) 32 max memory size
(kbytes, -m) unlimited open files
(-n) 1024 pipe size (512
bytes, -p) 8 POSIX message queues
(bytes, -q) 819200 real-time priority
(-r) 0 stack size
(kbytes, -s) 8192 cpu time
(seconds, -t) unlimited max user
processes (-u) 15863
virtual memory (kbytes, -v)
unlimited file locks
(-x) unlimited
I finally was able to see Apache's core dump in Ubuntu:
edit /etc/default/apport
edit apache2.conf:
CoreDumpDirectory /tmp/apache2-gdb-dump
make sure Apache can write to it:
# chmod 777 /tmp/apache2-gdb-dump
remove core dump size limit:
# ulimit -c unlimited
Optionally, change the name pattern of the core dumps:
# echo 'coredump-%e.%p' > /proc/sys/kernel/core_pattern
To analyse the dump use gdb:
$ gdb apache2 /tmp/apache2-gdb-dump/coredump-x.x
To see stacktrace details, in gdb:
gdb> where
This I did, and I obtained the core-dump.
However, my problem was not solved by looking at the coredump;
it was apparently an issue in my php script.
More info:
http://matrafox.info/apache-child-pid-exit-signal-segmentation-fault.html
Core dumps are disabled on Ubuntu by default
Try this:
ulimit -c unlimited
"ulimit -a" tells you what the current limit is (0 means disabled)
Do note that the subdirectory in /tmp will be removed after reboot, causing apache to not start due to configuration errors.
On a second note, the chowning is unnecessary. /tmp is chmodded 777 so anyone can read/write there.
#arod sudo ulimit -c does not work because -c is also an argument of sudo. You need to sudo -s, then ulimit -c

Categories