File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed
Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change 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"
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments