Status: New
Owner: ----

New issue 1741 by [email protected]: C++ use TryCatch in nested throws an unexpected exception.
http://code.google.com/p/v8/issues/detail?id=1741

For Code
#include <v8.h>
#include <stdio.h>

using namespace v8;

Handle<Value> foo(const Arguments &args)
{
        // another trycatch
        TryCatch trycatch;
        puts(*String::Utf8Value(args[0]));
        return v8::True();
}

int main()
{
        puts(V8::GetVersion());
        HandleScope scope;
        Handle<Context> context = Context::New();
        Context::Scope context_scope(context);

context->Global()->Set(String::New("foo"), FunctionTemplate::New(foo)->GetFunction());

        TryCatch trycatch;
Handle<Value> result = Script::New(String::New("foo('hello')"), String::New("core"))->Run();
        if (trycatch.HasCaught()) {
                puts(*String::Utf8Value(trycatch.Message()->Get()));
        }
        return 0;
}
----
It will output
3.6.5 (candidate)
hello
Uncaught undefined
----
the trycatch in main HasCaught() returns true. it not always happen, run 10 times about 8 times will show 'Uncaught undefined'. The script works right in 3.2.10.2

My environment is
gcc version 4.6.1 20110819 (prerelease) (GCC)
Linux myhost 3.0-ARCH #1 SMP PREEMPT Tue Aug 30 07:32:23 UTC 2011 i686 Intel(R) Atom(TM) CPU D510 @ 1.66GHz GenuineIntel GNU/Linux



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

Reply via email to