Skip to content

Commit 2242f59

Browse files
committed
tests: add ASAN repro for eval parse error in internal fake closure hook
Adds a PHPT that forces an eval() parse error inside an end-hook on an internal fake closure. Under ASAN this triggers a crash in ddtrace backtrace collection.
1 parent 32aaf0a commit 2242f59

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
--TEST--
2+
ASAN repro: internal fake closure + forced eval parse error
3+
--SKIPIF--
4+
<?php
5+
if (PHP_VERSION_ID < 80000) {
6+
die('skip: test requires PHP 8+');
7+
}
8+
?>
9+
--INI--
10+
datadog.trace.generate_root_span=0
11+
datadog.trace.auto_flush_enabled=0
12+
--ENV--
13+
DD_INSTRUMENTATION_TELEMETRY_ENABLED=0
14+
--FILE--
15+
<?php
16+
$closure = (new ReflectionFunction("intval"))->getClosure();
17+
18+
\DDTrace\install_hook(
19+
$closure,
20+
function () {},
21+
function () {
22+
// Intentionally invalid PHP code to force a ParseError from eval().
23+
eval('class Broken {');
24+
},
25+
\DDTrace\HOOK_INSTANCE
26+
);
27+
28+
$callable = $closure;
29+
$callable(1);
30+
31+
echo "ok\n";
32+
?>
33+
--EXPECT--
34+
ok
35+

0 commit comments

Comments
 (0)