mirror of
https://github.com/phpv8/v8js.git
synced 2024-12-22 08:11:52 +00:00
When FLAG_PROPAGATE_PHP_EXCEPTIONS is set, check for unwind or graceful exit before propagate
This commit is contained in:
parent
461230be27
commit
5a10dec698
37
tests/issue_497_001.phpt
Normal file
37
tests/issue_497_001.phpt
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
--TEST--
|
||||||
|
Test V8::executeString() : Issue #497 (segmentation fault calling PHP exit inside object function)
|
||||||
|
--SKIPIF--
|
||||||
|
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
class Foo {
|
||||||
|
function __destruct() {
|
||||||
|
var_dump('Foo __destruct');
|
||||||
|
}
|
||||||
|
|
||||||
|
function somecall() {
|
||||||
|
var_dump('Foo somecall');
|
||||||
|
}
|
||||||
|
|
||||||
|
function bar() {
|
||||||
|
global $v8;
|
||||||
|
var_dump('Foo bar');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$v8 = new \V8Js();
|
||||||
|
$v8->foo = new Foo();
|
||||||
|
|
||||||
|
$JS = <<< EOT
|
||||||
|
PHP.foo.somecall();
|
||||||
|
PHP.foo.bar();
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
$v8->executeString($JS, '', \V8JS::FLAG_PROPAGATE_PHP_EXCEPTIONS);
|
||||||
|
echo 'Not here!!';
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
string(12) "Foo somecall"
|
||||||
|
string(7) "Foo bar"
|
||||||
|
string(14) "Foo __destruct"
|
@ -167,7 +167,7 @@ failure:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(EG(exception)) {
|
if(EG(exception)) {
|
||||||
if(ctx->flags & V8JS_FLAG_PROPAGATE_PHP_EXCEPTIONS) {
|
if((ctx->flags & V8JS_FLAG_PROPAGATE_PHP_EXCEPTIONS) && !zend_is_graceful_exit(EG(exception)) && !zend_is_unwind_exit(EG(exception))) {
|
||||||
zval tmp_zv;
|
zval tmp_zv;
|
||||||
ZVAL_OBJ(&tmp_zv, EG(exception));
|
ZVAL_OBJ(&tmp_zv, EG(exception));
|
||||||
return_value = isolate->ThrowException(zval_to_v8js(&tmp_zv, isolate));
|
return_value = isolate->ThrowException(zval_to_v8js(&tmp_zv, isolate));
|
||||||
|
Loading…
Reference in New Issue
Block a user