I'm trying to Enter a Context in one Locker, then use it in another:
v8::Isolate *isolate = v8::Isolate::New();
{
v8::Locker locker(isolate);
isolate->Enter();
}
v8::Persistent<v8::Context> pctxt;
{
v8::Locker locker(isolate);
v8::HandleScope handleScope(isolate);
v8::Local<v8::Context> ctxt = v8::Context::New(isolate);
ctxt->Enter();
pctxt.Reset(isolate, ctxt);
} // Error occurs here, on locker dtor
{
v8::Locker locker(isolate);
v8::HandleScope handleScope(isolate);
v8::Local<v8::Context> ctxt =
v8::Local<v8::Context>::New(isolate, pctxt);
ctxt->Exit();
}
This causes an assertion failure in a debug build:
# Fatal error in ../src/api.h, line 577
# CHECK(entered_contexts_.length() == 0) failed
and a fatal error in a release build:
# Fatal error in v8::Context::Exit()
# Cannot exit non-entered context
The assertion fails because the dtor of a top-level Locker releases
thread-local resources, which includes the list of entered contexts.
I'm able to work around this by heap-allocating a Locker/Unlocker pair
after entering the isolate (before the declaration of pctxt):
v8::Locker *toplock = new v8::Locker(isolate);
v8::Unlocker *topunlock = new v8::Unlocker(isolate);
and deleting them when I dispose of the isolate, but this is ugly and goes
counter to the way I see these APIs being used.
Is there a better way to solve this problem?
--
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.