Skip to content
This repository was archived by the owner on Mar 29, 2024. It is now read-only.

Commit a968c64

Browse files
committed
Fix segfault on shutdown during value self-cleanup
It happens when value tries to clenup itself but isolate was already destroyed
1 parent 6e48845 commit a968c64

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

Diff for: src/php_v8_value.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static void php_v8_value_free(zend_object *object) {
108108
php_v8_value_t *php_v8_value = php_v8_value_fetch_object(object);
109109

110110
// TODO: check whether we have valid isolate?
111-
if (php_v8_value->php_v8_isolate && php_v8_value->persistent && !php_v8_value->persistent->IsEmpty()) {
111+
if (PHP_V8_IS_UP_AND_RUNNING() && php_v8_value->php_v8_isolate && php_v8_value->persistent && !php_v8_value->persistent->IsEmpty()) {
112112
PHP_V8_ENTER_STORED_ISOLATE(php_v8_value);
113113

114114
// TODO: in general, this makes sense only for objects

Diff for: tests/010-no-value-self-cleanup-on-shutdown.phpt

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Built-in enum classes
3+
--SKIPIF--
4+
<?php if (!extension_loaded("v8")) {
5+
print "skip";
6+
} ?>
7+
--FILE--
8+
<?php
9+
10+
/** @var \Phpv8Testsuite $helper */
11+
$helper = require '.testsuite.php';
12+
13+
$enums = [
14+
new V8\StringValue(new V8\Isolate()),
15+
];
16+
17+
foreach ($enums as $enum) {
18+
$rc = new ReflectionClass($enum);
19+
}
20+
21+
echo 'done', PHP_EOL;
22+
23+
?>
24+
--EXPECT--
25+
done

0 commit comments

Comments
 (0)