Skip to content

Instantly share code, notes, and snippets.

@salahm
Forked from lyrixx/segfault-finder.php
Created July 19, 2016 13:29
Show Gist options
  • Save salahm/e480e705b5957d3403097a8bc041b1ea to your computer and use it in GitHub Desktop.
Save salahm/e480e705b5957d3403097a8bc041b1ea to your computer and use it in GitHub Desktop.
How to find a segfault in PHP
<?php
register_tick_function(function() {
$bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
$last = reset($bt);
echo sprintf("%s +%d\n", $last['file'], $last['line']);
});
declare(ticks=1);
function foobar()
{
$c = 1;
$d = 1;
// segfault
// $d = 1;
}
foobar();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment