title: Calling callback from node.js native code
body: <p>I'm writing an add-on for node.js using c++.</p>
  
  <p>here some snippets:</p>
  
  <pre><code>class Client : public node::ObjectWrap, public someObjectObserver {
  public:
    void onAsyncMethodEnds() {
      Local&lt;Value&gt; argv[] = { Local&lt;Value&gt;::New(String::New("TheString")) };
      this-&gt;callback-&gt;Call(Context::GetCurrent()-&gt;Global(), 1, argv);
    }
  ....
  private:
    static v8::Handle&lt;v8::Value&gt; BeInitiator(const v8::Arguments&amp; args) {
      HandleScope scope;
      Client* client = ObjectWrap::Unwrap&lt;Client&gt;(args.This());
  
      client-&gt;someObject-&gt;asyncMethod(client, NULL);
  
      return scope.Close(Boolean::New(true));        
    }      
  
    static v8::Handle&lt;v8::Value&gt; SetCallback(const v8::Arguments&amp; args) {
      HandleScope scope;
      Client* client = ObjectWrap::Unwrap&lt;Client&gt;(args.This());
      client-&gt;callback = Persistent&lt;Function&gt;::New(Handle&lt;Function&gt;::Cast(args[0]));
  
      return scope.Close(Boolean::New(true));
    }
  </code></pre>
  
  <p>I need to save a javascript function as callback to call it later. 
  The Client class is an observer for another object and the javascript callback should be called from onAsyncMethodEnds.
  Unfortunately when I call the function "BeInitiator" I receive "Bus error: 10" error just before the callback Call()</p>
  
  <p>thanks in advice</p>