- Enable the tracer on your xdebug.ini file (see the
xdebug.ini
file). - If you are gonna trace an http request, make sure your
xdebug.trace_output_dir
is writable by the webserver user (www-data). - Execute your script or your request. You can use
produce_segmentation.php
to test. - See the trace file(s) on your
xdebug.trace_output_dir
.
Last active
May 8, 2017 16:41
-
-
Save smoya/c49144f01470ebb403df to your computer and use it in GitHub Desktop.
Get php trace -on segmentation fault- using xdebug
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 | |
class foo { | |
function fail() | |
{ | |
// This preg_match will produce segmentation fault | |
// .ru because Russian people love Adidas jackets like I do. http://weirdrussia.com/2015/01/04/why-is-adidas-so-popular-among-russians | |
preg_match("/http:\/\/(.)+\.ru/i", str_repeat("http://google.ru", 2000)); | |
} | |
} | |
class bar { | |
function doit() | |
{ | |
$destroyer = new foo(); | |
$destroyer->fail(); | |
} | |
} | |
$obj = new bar(); | |
$obj->doit(); |
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
; Example: /etc/php5/mods-available/xdebug.ini | |
[xdebug] | |
zend_extension=/usr/lib/php5/20121212/xdebug.so ; Path to your extension | |
xdebug.auto_trace=1 | |
xdebug.trace_output_dir=/tmp/segmentation/ ; Or whatever path you want to use |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment