[英]Segmentation fault in v8 hello world when using TryCatch
I am trying to use v8 in my C++ application. 我正在尝试在C ++应用程序中使用v8。 I am stuck on the helloworld itself!
我被helloworld困住了!
The helloworld at https://developers.google.com/v8/get_started works just fine. https://developers.google.com/v8/get_started上的helloworld工作正常。 Now I am trying to catch exceptions/error in the code.
现在,我试图捕获代码中的异常/错误。 So I used TryCatch trycatch;.
所以我用了TryCatch trycatch;。
int main(int argc, char *argv[]) {
HandleScope handle_scope;
Persistent<Context> context = Context::New();
Context::Scope context_scope(context);
TryCatch trycatch; /* TO CATCH EXCETIONS/ERRORS */
Handle<String> source = String::New("xyz();");
Handle<Script> script = Script::Compile(source);
Handle<Value> result = script->Run();
if (result.IsEmpty()) {
fprintf(stderr, "Exception: %s\n",
*String::AsciiValue(trycatch.Exception()));
return -1;
}
String::AsciiValue ascii(result);
printf("%s\n", *ascii);
context.Dispose();
return 0;
}
The exceptions are caught fine but the program does not terminate properly. 可以很好地捕获异常,但是程序无法正常终止。 It generates a segmentation fault.
它会产生分段错误。 What am I doing wrong?
我究竟做错了什么?
Turned out to be a foolish thing. 原来是愚蠢的事情。 I had long back installed libv8-dev and forgotten about it.
我早就安装了libv8-dev并忘记了它。 And now I installed V8 from source.
现在,我从源代码安装了V8。 So I had two versions of V8 on my system.
因此,我的系统上有两个版本的V8。 I uninstalled libv8-dev and the problem has been solved.
我卸载了libv8-dev,问题已解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.