Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I debug segmentation faults in the PHP CLI?

I have written some code that I run remotely on a server via the php-cli and a particular method within this code (I'm unsure which method at the moment) is causing a segmentation fault.

Apart from adding exit and echo calls down through my methods and manually pinpointing the bad bits - is there a way to catch the segmentation fault as it happens and find out what piece of the puzzle is crashing? Standard PHP errors are displayed through the error shutdown handlers, I'm unsure where to start with this segmentation fault.

Cheers!

like image 620
Jessedc Avatar asked Jul 17 '12 07:07

Jessedc


People also ask

What causes PHP segmentation fault?

A segmentation fault occurs because of the Memory Access Violation. Means, the error occurs when a program tries to access a block of memory which you are not allowed to access. Or to make it concise, you are approaching memory location which doesn't belong to you. In short, it is also known as a segfault.


1 Answers

Yes. With the GNU Debugger: how-to-debug-a-segmentation-fault-caused-by-php

Or by setting the flag DBIG_SECURITY_HOLE when you compile php: Fixing Apache Segmentation Faults Caused by PHP

Take a look at bugs.php.net maybe there is a related known bug in the PHP source.

like image 186
Besnik Avatar answered Sep 19 '22 13:09

Besnik