Skip to content

Commit c55b2cc

Browse files
committed
#50: fix JIT PHP issue with opcache.jit_hot_func=1 and bailout tests
1 parent 07b9eb6 commit c55b2cc

6 files changed

+26
-41
lines changed

tests/bailout/003-stack-overflow-simple.phpt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ if ($zend_mm_enabled === "0") {
77
die("skip Zend MM disabled");
88
}
99
?>
10+
--INI--
11+
opcache.jit_hot_func=0
1012
--FILE--
1113
<?php
1214

@@ -16,13 +18,9 @@ function deepRecursion($depth = 0) {
1618
return deepRecursion($depth + 1);
1719
}
1820

19-
$function = function(bool $out = true) {
20-
if($out) echo "Shutdown function called\n";
21-
};
22-
23-
$function(false);
24-
25-
register_shutdown_function($function);
21+
register_shutdown_function(function() {
22+
echo "Shutdown function called\n";
23+
});
2624

2725
echo "Before spawn\n";
2826

tests/bailout/004-stack-overflow-nested.phpt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
Stack overflow bailout in nested async operations
3+
--INI--
4+
opcache.jit_hot_func=0
35
--SKIPIF--
46
<?php
57
$zend_mm_enabled = getenv("USE_ZEND_ALLOC");
@@ -16,13 +18,9 @@ function deepRecursion($depth = 0) {
1618
return deepRecursion($depth + 1);
1719
}
1820

19-
$function = function(bool $out = true) {
20-
if($out) echo "Shutdown function called\n";
21-
};
22-
23-
$function(false);
24-
25-
register_shutdown_function($function);
21+
register_shutdown_function(function() {
22+
echo "Shutdown function called\n";
23+
});
2624

2725
echo "Before spawn\n";
2826

tests/bailout/005-memory-exhaustion-during-suspend.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ After suspend
4646
Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d
4747

4848
Warning: Graceful shutdown mode was started in %s on line %d
49-
Shutdown function called
49+
Shutdown function called

tests/bailout/007-stack-overflow-with-suspend.phpt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
Stack overflow bailout with suspend in recursion
3+
--INI--
4+
opcache.jit_hot_func=0
35
--SKIPIF--
46
<?php
57
$zend_mm_enabled = getenv("USE_ZEND_ALLOC");
@@ -20,13 +22,9 @@ function deepRecursionWithSuspend($depth = 0) {
2022
return deepRecursionWithSuspend($depth + 1);
2123
}
2224

23-
$function = function(bool $out = true) {
24-
if($out) echo "Shutdown function called\n";
25-
};
26-
27-
$function(false);
28-
29-
register_shutdown_function($function);
25+
register_shutdown_function(function() {
26+
echo "Shutdown function called\n";
27+
});
3028

3129
echo "Before spawn\n";
3230

tests/bailout/011-stack-overflow-during-await.phpt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
Stack overflow bailout during await operation
3+
--INI--
4+
opcache.jit_hot_func=0
35
--SKIPIF--
46
<?php
57
$zend_mm_enabled = getenv("USE_ZEND_ALLOC");
@@ -17,13 +19,9 @@ function deepRecursion($depth = 0) {
1719
return deepRecursion($depth + 1);
1820
}
1921

20-
$function = function(bool $out = true) {
21-
if($out) echo "Shutdown function called\n";
22-
};
23-
24-
$function(false);
25-
26-
register_shutdown_function($function);
22+
register_shutdown_function(function() {
23+
echo "Shutdown function called\n";
24+
});
2725

2826
echo "Before spawn\n";
2927

tests/bailout/014-stack-overflow-with-finally.phpt

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
Stack overflow bailout with onFinally handlers
3+
--INI--
4+
opcache.jit_hot_func=0
35
--SKIPIF--
46
<?php
57
$zend_mm_enabled = getenv("USE_ZEND_ALLOC");
@@ -25,18 +27,9 @@ echo "Before scope\n";
2527

2628
$scope = new Scope();
2729

28-
$finally = function($x = false, $out = true) {
29-
if($out) {
30-
echo "Finally handler executed\n";
31-
}
32-
};
33-
34-
// JIT PHP in tracing mode can compile functions on demand. When memory runs out,
35-
// JIT crashes with an error because it tries to compile a closure.
36-
// This code attempts to work around the issue so that the test runs correctly.
37-
$finally(false, false);
38-
39-
$scope->onFinally($finally);
30+
$scope->onFinally(function() {
31+
echo "Finally handler executed\n";
32+
});
4033

4134
$coroutine = $scope->spawn(function() {
4235
echo "Before stack overflow\n";

0 commit comments

Comments
 (0)