From c52a9943e2fd4a2fec4d21f064376d2f518d538d Mon Sep 17 00:00:00 2001 From: Christian Flach Date: Mon, 19 Feb 2018 14:53:35 +0100 Subject: [PATCH 1/2] Correctly deinitialize context --- src/node.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/node.cc b/src/node.cc index b0d22f97067..c91bdcc06ce 100644 --- a/src/node.cc +++ b/src/node.cc @@ -4535,7 +4535,8 @@ int _StopEnv() { context_scope = nullptr; if (!context.IsEmpty()) { - delete *context; + // No need to delete the context value (delete *context), + // this is already done by deleting the context_scope above. context.Clear(); } @@ -4755,8 +4756,9 @@ void Initialize(int argc, const char** argv, const bool allow_repl) { int Deinitialize() { // Empty event queue - Evaluate("process.exit();"); - while (ProcessEvents()) { } + // TODO(cf): Investigate when this is really needed. + //Evaluate("process.exit();"); + //while (ProcessEvents()) { } auto exit_code = deinitialize::_StopEnv(); From 6d53a55221f23f644279c0ed617b347b2996837e Mon Sep 17 00:00:00 2001 From: Christian Flach Date: Mon, 19 Feb 2018 15:37:09 +0100 Subject: [PATCH 2/2] Fix style, remove debug output --- src/node.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/node.cc b/src/node.cc index c91bdcc06ce..3263a797a22 100644 --- a/src/node.cc +++ b/src/node.cc @@ -4677,8 +4677,6 @@ void _StartEnv(int argc, int v8_argc, const char* const* v8_argv, const bool allow_repl) { - std::cout << "Starting environment" << std::endl; - _environment->Start(argc, argv, v8_argc, v8_argv, v8_is_profiling); const char* path = argc > 1 ? argv[1] : nullptr; @@ -4757,8 +4755,8 @@ void Initialize(int argc, const char** argv, const bool allow_repl) { int Deinitialize() { // Empty event queue // TODO(cf): Investigate when this is really needed. - //Evaluate("process.exit();"); - //while (ProcessEvents()) { } + // Evaluate("process.exit();"); + // while (ProcessEvents()) { } auto exit_code = deinitialize::_StopEnv();