I'm not sure what in the world's causing this crash. The stack trace
from gdb isn't much help.

Program received signal SIGSEGV, Segmentation fault.
0x003a2ab9 in ?? ()
(gdb) bt
#0  0x003a2ab9 in ?? ()
#1  0x003a2a94 in ?? ()
#2  0xb6072389 in ?? ()
#3  0x0baddead in ?? ()
#4  0x003a29e1 in ?? ()
#5  0x0000000a in ?? ()

Valgrind gives a little more info;

==14169== Invalid read of size 4
==14169==    at 0x4B1C599: ???
==14169==    by 0x4B1C95D: ???
==14169==    by 0x4B02CDA: ???
==14169==    by 0x4B022E1: ???
==14169==    by 0x480E21A: v8::internal::Invoke(bool,
v8::internal::Handle<v8::internal::JSFunction>,
v8::internal::Handle<v8::internal::Object>, int,
v8::internal::Object***, bool*) (execution.cc:94)
==14169==    by 0x480E306:
v8::internal::Execution::Call(v8::internal::Handle<v8::internal::JSFunction>,
v8::internal::Handle<v8::internal::Object>, int,
v8::internal::Object***, bool*) (execution.cc:121)
==14169==    by 0x47D01D6: v8::Script::Run() (api.cc:1242)
==14169==    by 0x47CAE02: scope_run(SuperScopePrivate*,
scope_runnable) (actor_avs_superscope.cpp:190)
==14169==    by 0x47CC0BC: lv_superscope_render
(actor_avs_superscope.cpp:499)
==14169==    by 0x402FCB0: visual_actor_run (lv_actor.c:777)
==14169==    by 0x4072EEF: pipeline_container_run (lvavs_pipeline.c:
506)
==14169==    by 0x40725EE: lvavs_pipeline_run (lvavs_pipeline.c:209)
==14169==  Address 0xbaddeac is not stack'd, malloc'd or (recently)
free'd

Here's the script that's being run when the crash happens:
d=i+v*0.2; r=t+i*PI*4; x=cos(r)*d; y=sin(r)*d

It crashes right before assigning x.

Here's where I compile and run the script:
int scope_load_runnable(SuperScopePrivate *priv, ScopeRunnable
runnable, char *buf)
{
    printf("buf ------- %s %d\n", buf, (int)runnable);
    HandleScope handle_scope;

    Handle<Context> context = Context::New(NULL, priv->global);
    Context::Scope context_scope(context);
    Handle<String> source_obj = String::New(buf);
    Persistent<Script> script =
Persistent<Script>::New(Script::Compile(source_obj));
    priv->runnable[runnable] = script;

    return 0;
}

int scope_run(SuperScopePrivate *priv, ScopeRunnable runnable)
{
    printf("scope_run ---------- %d\n", (int)runnable);
    HandleScope handle_scope;

    Handle<Context> context = Context::New(NULL, priv->global);
    Context::Scope context_scope(context);
    priv->runnable[runnable]->Run();

    return 0;
}

Here's the getter and setter:
#define GETTER(name) \
    static Handle<Value> prop_getter_##name(Local<String> property,
const AccessorInfo &info) { \
        Handle<Value> obj(*info.Data()); \
        SuperScopePrivate *priv = (SuperScopePrivate
*)External::Unwrap(obj); \
        printf("getter for %s = %f\n", *String::Value(property), priv-
>name); \
        return Number::New(priv->name); \
    }

#define SETTER(name) \
    static void prop_setter_##name(Local<String> property,
Local<Value> val, const AccessorInfo &info) { \
        Handle<Value> obj(*info.Data()); \
        SuperScopePrivate *priv = (SuperScopePrivate
*)External::Unwrap(obj); \
        priv->name = val->ToNumber()->Value(); \
        printf("setter for %s = %f\n", *String::Value(property), priv-
>name);\
    }

Here's cos:
static Handle<Value> function_cos(const Arguments &args)
{
        printf("function_cos\n");
        HandleScope handle_scope;

        if (args.Length() != 1)
                return v8::Undefined();


        Handle<Value> val = Number::New(log(args[0]->NumberValue()));

        return val;
}

And here's some output:
getter for i = 0.000000
getter for v = 0.199020
setter for d = 0.039804
getter for t = -0.050000
getter for i = 0.000000
getter PI
function_cos
getter for d = 0.039804

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

Reply via email to