Skip to content

Commit d8ca30a

Browse files
author
epriestley
committed
Add a failing test case for the XHProf PHP 5.5 segfault
Summary: This adds a failing test case for the bug discussed in <phacility#33>. It also adds a `bin/xhprofile` script which makes it easier to test stuff like this, by invoking the profiler on some other script. This isn't hugely useful in production but is valuable diagnostically, and helped me reduce this test case. Test Plan: - Ran `arc unit` and got a failure. - Verified that this test passes if `class_exists()` is commented out (which makes the test not segfault). Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D10374
1 parent a39446c commit d8ca30a

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

bin/xhprofile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../scripts/xhprofile.php

extension/tests/xhprof_009.phpt

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
XHPRrof: PHP 5.5 crash in hp_execute_internal
3+
Author: epriestley
4+
--FILE--
5+
<?php
6+
7+
function loader() {
8+
// <empty>
9+
}
10+
11+
spl_autoload_register('loader', $throw = true);
12+
13+
xhprof_enable();
14+
15+
class_exists('ThisClassDoesNotExist');
16+
echo "OK\n";
17+
18+
--EXPECT--
19+
OK

scripts/xhprofile.php

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
// Profile a CLI script.
5+
6+
if ($argc < 2) {
7+
throw new Exception('usage: xhprofile <script>');
8+
}
9+
10+
$__xhprof_target__ = $argv[1];
11+
12+
$argv = array_slice($argv, 1);
13+
$argc = count($argv);
14+
15+
xhprof_enable();
16+
require_once $__xhprof_target__;
17+
$xhprof_data = xhprof_disable();
18+
19+
var_dump($xhprof_data);

0 commit comments

Comments
 (0)