Skip to content

Commit 8aa6bc2

Browse files
committed
Merge branch 'php8-exit_segfault' of https://github.com/chrisbckr/v8js into php8
Conflicts: v8js_object_export.cc
2 parents 7887ec6 + 5a10dec commit 8aa6bc2

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

tests/issue_497_001.phpt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
Test V8::executeString() : Issue #497 (segmentation fault calling PHP exit inside object function)
3+
--SKIPIF--
4+
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
5+
--FILE--
6+
<?php
7+
class Foo {
8+
function __destruct() {
9+
var_dump('Foo __destruct');
10+
}
11+
12+
function somecall() {
13+
var_dump('Foo somecall');
14+
}
15+
16+
function bar() {
17+
global $v8;
18+
var_dump('Foo bar');
19+
exit;
20+
}
21+
}
22+
23+
$v8 = new \V8Js();
24+
$v8->foo = new Foo();
25+
26+
$JS = <<< EOT
27+
PHP.foo.somecall();
28+
PHP.foo.bar();
29+
EOT;
30+
31+
$v8->executeString($JS, '', \V8JS::FLAG_PROPAGATE_PHP_EXCEPTIONS);
32+
echo 'Not here!!';
33+
?>
34+
--EXPECTF--
35+
string(12) "Foo somecall"
36+
string(7) "Foo bar"
37+
string(14) "Foo __destruct"

v8js_object_export.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ v8::Local<v8::Value> v8js_propagate_exception(v8js_ctx *ctx) /* {{{ */
3838
{
3939
v8::Local<v8::Value> return_value = v8::Null(ctx->isolate);
4040

41-
if (!(ctx->flags & V8JS_FLAG_PROPAGATE_PHP_EXCEPTIONS)) {
41+
if (!(ctx->flags & V8JS_FLAG_PROPAGATE_PHP_EXCEPTIONS) || zend_is_graceful_exit(EG(exception)) || zend_is_unwind_exit(EG(exception))) {
4242
v8js_terminate_execution(ctx->isolate);
4343
return return_value;
4444
}

0 commit comments

Comments
 (0)