Last active
May 3, 2024 17:10
-
-
Save arungpro/e6853887043410d5bb950a0ba2df0db2 to your computer and use it in GitHub Desktop.
Core dumps and gdb backtrace for php-fpm and apache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#PHP Apache CORE DUMP - GDB backtrace | |
Open httpd.conf: | |
vi httpd.conf | |
Add following line main config section: | |
```CoreDumpDirectory /tmp/apache2-gdb-dump``` | |
Unlimited core dump size, In terminal add below | |
```ulimit -c unlimited``` | |
Create a directory /tmp/apache2-gdb-dump: | |
```mkdir -p /tmp/apache2-gdb-dump``` | |
Set permission: | |
```chown httpd:appserver /tmp/apache2-gdb-dump | |
chmod 0777 /tmp/apache2-gdb-dump``` | |
Now you should see core dumps in /tmp/apache2-gdb-dump directory: | |
```ls /tmp/apache2-gdb-dump``` | |
Install GDB | |
```yum install gdb``` or ```apt-get install gdb``` or ```.....check online``` | |
Reading the core dumps | |
```gdb $program-path $coredump-path or gdb -c <core_file> `which <program-path>` | |
Example: | |
gdb /usr/sbin/php-fpm /tmp/apache2-gdb-dump``` | |
with in GDB | |
``` | |
* set disassembly-flavor intel | |
* set logging on | |
* bt full | |
* info reg | |
* disassemble | |
* info shared | |
* Info threads | |
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#PHP-FPM CORE DUMP - GDB backtrace | |
Check if core dump is enabled or not | |
``` | |
ls /tmp/coredump* | |
``` | |
If not, Enable core dumps | |
1. Create core dump file and point to the kernel core_pattern | |
``` | |
echo '/tmp/coredump-%e.%p' > /proc/sys/kernel/core_pattern | |
``` | |
2. Open your php-fpm pool configuration and add | |
``` | |
rlimit_core = unlimited | |
``` | |
Unlimited core dump size, In terminal add below | |
``` | |
ulimit -c unlimited | |
``` | |
Install GDB | |
```yum install gdb``` or ```apt-get install gdb``` or ```.....check online``` | |
Reading the core dumps | |
```gdb $program-path $coredump-path or gdb -c <core_file> `which <program-path>` | |
Example: | |
gdb /usr/sbin/php-fpm /tmp/coredump-php-fpm.2393``` | |
with in GDB | |
``` | |
* set disassembly-flavor intel | |
* set logging on | |
* bt full | |
* info reg | |
* disassemble | |
* info shared | |
* Info threads | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
disassembly to disassemble