Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Commit 9a6012e

Browse files
laverdetbnoordhuis
authored andcommitted
Re-add top-level v8::Locker
11d1eca added a v8 locker to ease development of 3rd party threading extensions but it created a condition which would cause node to exit uncleanly while in debug mode; it was reverted in 7543c38. The problem here is that the Locker was being disposed after V8 was torn down. Adding some scoping fixes that.
1 parent e612143 commit 9a6012e

1 file changed

Lines changed: 29 additions & 23 deletions

File tree

src/node.cc

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2644,32 +2644,38 @@ int Start(int argc, char *argv[]) {
26442644
// This needs to run *before* V8::Initialize()
26452645
argv = Init(argc, argv);
26462646

2647-
v8::V8::Initialize();
2648-
v8::HandleScope handle_scope;
2649-
2650-
// Create the one and only Context.
2651-
Persistent<v8::Context> context = v8::Context::New();
2652-
v8::Context::Scope context_scope(context);
2653-
2654-
Handle<Object> process_l = SetupProcessObject(argc, argv);
2655-
v8_typed_array::AttachBindings(context->Global());
2656-
2657-
// Create all the objects, load modules, do everything.
2658-
// so your next reading stop should be node::Load()!
2659-
Load(process_l);
2660-
2661-
// All our arguments are loaded. We've evaluated all of the scripts. We
2662-
// might even have created TCP servers. Now we enter the main eventloop. If
2663-
// there are no watchers on the loop (except for the ones that were
2664-
// uv_unref'd) then this function exits. As long as there are active
2665-
// watchers, it blocks.
2666-
uv_run(uv_default_loop());
2667-
2668-
EmitExit(process_l);
2647+
V8::Initialize();
2648+
Persistent<Context> context;
2649+
{
2650+
Locker locker;
2651+
HandleScope handle_scope;
2652+
2653+
// Create the one and only Context.
2654+
Persistent<Context> context = Context::New();
2655+
Context::Scope context_scope(context);
2656+
2657+
Handle<Object> process_l = SetupProcessObject(argc, argv);
2658+
v8_typed_array::AttachBindings(context->Global());
2659+
2660+
// Create all the objects, load modules, do everything.
2661+
// so your next reading stop should be node::Load()!
2662+
Load(process_l);
2663+
2664+
// All our arguments are loaded. We've evaluated all of the scripts. We
2665+
// might even have created TCP servers. Now we enter the main eventloop. If
2666+
// there are no watchers on the loop (except for the ones that were
2667+
// uv_unref'd) then this function exits. As long as there are active
2668+
// watchers, it blocks.
2669+
uv_run(uv_default_loop());
2670+
2671+
EmitExit(process_l);
2672+
#ifndef NDEBUG
2673+
context.Dispose();
2674+
#endif
2675+
}
26692676

26702677
#ifndef NDEBUG
26712678
// Clean up.
2672-
context.Dispose();
26732679
V8::Dispose();
26742680
#endif // NDEBUG
26752681

0 commit comments

Comments
 (0)