mirror of
https://github.com/phpv8/v8js.git
synced 2025-01-03 16:51:52 +00:00
Merge pull request #147 from stesie/issue-135
Enter endless loop after V8::TerminateExecution call, fixes #135
This commit is contained in:
commit
f6eacd59d0
@ -27,7 +27,21 @@ void v8js_commonjs_normalise_identifier(char *base, char *identifier, char *norm
|
|||||||
/* global.exit - terminate execution */
|
/* global.exit - terminate execution */
|
||||||
V8JS_METHOD(exit) /* {{{ */
|
V8JS_METHOD(exit) /* {{{ */
|
||||||
{
|
{
|
||||||
v8::V8::TerminateExecution(info.GetIsolate());
|
v8::Isolate *isolate = info.GetIsolate();
|
||||||
|
|
||||||
|
/* Unfortunately just calling TerminateExecution on the isolate is not
|
||||||
|
* enough, since v8 just marks the thread as "to be aborted" and doesn't
|
||||||
|
* immediately do so. Hence we enter an endless loop after signalling
|
||||||
|
* termination, so we definitely don't execute JS code after the exit()
|
||||||
|
* statement. */
|
||||||
|
v8::Locker locker(isolate);
|
||||||
|
v8::Isolate::Scope isolate_scope(isolate);
|
||||||
|
v8::HandleScope handle_scope(isolate);
|
||||||
|
|
||||||
|
v8::Local<v8::String> source = V8JS_STR("for(;;);");
|
||||||
|
v8::Local<v8::Script> script = v8::Script::Compile(source);
|
||||||
|
v8::V8::TerminateExecution(isolate);
|
||||||
|
script->Run();
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user