Although this is in the example, my guess is because you are disposing of
the context before the scope exits. That HandleScope is going to try to
destruct every local handle you create in this scope ( of which you created
three ). If you destroy the context before the scope exits, I imagine most
of those would be null handles. I think I remember having a similar
problem, and removing that line "fixed" it for me.

Hope that helps

On Mon, Jul 30, 2012 at 6:43 PM, Anand Kumar <[email protected]>wrote:

>
>   I am trying to use v8 in my C++ application. I am stuck on the
> helloworld itself!
>
> The helloworld at https://developers.google.com/v8/get_started works just
> fine. Now I am trying to catch exceptions/error in the code. So I used
> 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?
>
> Note: I am running 64-bit Ubuntu 11.10. I have compiled v8 source code using 
> make native.
>
>  --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to