diff --git a/tests/issue_497_001.phpt b/tests/issue_497_001.phpt new file mode 100644 index 0000000..deb3daf --- /dev/null +++ b/tests/issue_497_001.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test V8::executeString() : Issue #497 (segmentation fault calling PHP exit inside object function) +--SKIPIF-- + +--FILE-- +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" diff --git a/v8js_object_export.cc b/v8js_object_export.cc index be8cd8b..967f6ac 100644 --- a/v8js_object_export.cc +++ b/v8js_object_export.cc @@ -38,7 +38,7 @@ v8::Local v8js_propagate_exception(v8js_ctx *ctx) /* {{{ */ { v8::Local return_value = v8::Null(ctx->isolate); - 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))) { v8js_terminate_execution(ctx->isolate); return return_value; }