调用LoadEnvironment时出现段错误

时间:2017-12-18 11:11:32

标签: c++ node.js

我正在尝试在C ++应用程序中嵌入节点。将--shared编译成/opt/node<version>前缀的节点。

当我使用节点9.2时,我的代码工作正常。但是,当我尝试使用节点9.3的相同代码时,我会在LoadEnvironment上获得段错误。

以下是代码的开头,您可以查看所有代码here(在version中切换Makefile以查看错误。)

  const char *argv[] = {"js"};
  int argc = sizeof(argv) / sizeof(char *);

  uv_loop_t *loop = new uv_loop_t;
  uv_loop_init(loop);

  int exec_argc;
  const char** exec_argv;
  Init(&argc, argv, &exec_argc, &exec_argv);

  V8::InitializeICUDefaultLocation("js");
  V8::InitializeExternalStartupData("js");
  Platform *platform = v8::platform::CreateDefaultPlatform();
  V8::InitializePlatform(platform);
  V8::Initialize();


  Isolate::CreateParams create_params;
  create_params.array_buffer_allocator =
      ArrayBuffer::Allocator::NewDefaultAllocator();
  Isolate *isolate = Isolate::New(create_params);

  HandleScope handle_scope(isolate);
  auto context = Context::New(isolate);
  Context::Scope context_scope(context);

  IsolateData *isolate_data = CreateIsolateData(isolate, loop);
  Environment* env = CreateEnvironment(
        isolate_data, context, argc, argv, exec_argc, exec_argv);
  std::cout << ">>> HERE <<<\n";
  LoadEnvironment(env);
  std::cout << ">>> HERE <<<\n";

0 个答案:

没有答案