Failure in call from addon into node New string using Nan

88 views
Skip to first unread message

Stephen James

unread,
Apr 23, 2016, 4:59:29 PM4/23/16
to nodejs
Attempting to call from c++ to v8 using async.c using Nan::New<v8::String>() I keep ending up with the following
abort. 

void EventConnectedAsync(uv_async_t *handle)
{
  if (!EventConnectedCB.IsEmpty())
  {
    cout << (char*)handle->data << endl;
    const char* url = (const char*)handle->data;
    v8::Local<v8::Value> argv[] = { Nan::New<v8::String>(url).ToLocalChecked() };  // at node_nzape_cb.cc:36

    Nan::MakeCallback(Nan::GetCurrentContext()->Global(), EventConnectedCB, 1, argv);

    delete [] (char*)handle->data;
  }
}

00007F869F3407B0 _ZL12getBackTracev
00007F869F340DE7 _ZL19signalSevereHandleri
00007F86A1B66CC9 gsignal
00007F86A1B6A0D7 abort
0000000000DFB22B _ZN4nodeL12OnFatalErrorEPKcS1_
00000000008CA0D4 _ZN2v85Utils16ReportApiFailureEPKcS2_
0000000000A9843E _ZN2v88internal11HandleScope6ExtendEPNS0_7IsolateE
00000000008E3D00 _ZN2v88internal11HandleScope12CreateHandleINS0_6ObjectEEEPPT_PNS0_7IsolateES5_
0000000000A79A2A _ZN2v88internal7Factory19NewRawOneByteStringEiNS0_13PretenureFlagE
0000000000A792E2 _ZN2v88internal7Factory20NewStringFromOneByteENS0_6VectorIKhEENS0_13PretenureFlagE
0000000000A79F92 _ZN2v88internal7Factory17NewStringFromUtf8ENS0_6VectorIKcEENS0_13PretenureFlagE
00000000008DA092 _ZN2v86String11NewFromUtf8EPNS_7IsolateEPKcNS_13NewStringTypeEi
00007F869F8FF84F Nan::imp::Factory<v8::String>::New(char const*, int) at nan_implementation_12_inl.h:265
00007F869F8FFE2B Nan::imp::Factory<v8::String>::return_t Nan::New<v8::String, char const*>(char const*) at nan_new.h:208
00007F869F901061 EventConnectedAsync(uv_async_s*) at node_nzape_cb.cc:36
0000000000FBF91A uv__async_event at async.c:98
0000000000FBF9F2 uv__async_io at async.c:138
0000000000FCFA34 uv__io_poll at linux-core.c:345
0000000000FC04D5 uv_run at core.c:351
0000000000E088AF _ZN4node5StartEiPPc
00007F86A1B51EC4 __libc_start_main
Build:  Date:Apr 19 2016 13:26:06  Version:10037 
Aborted (core dumped)
nzos@nzos-VirtualBox:~/Development/node-nzape$ nodejs
The program 'nodejs' is currently not installed. You can install it by typing:
sudo apt-get install nodejs
nzos@nzos-VirtualBox:~/Development/node-nzape$ node --version
v5.10.1

Ben Noordhuis

unread,
Apr 24, 2016, 11:42:14 AM4/24/16
to nod...@googlegroups.com
It looks like you're missing a v8::HandleScope or Nan::HandleScope at
the top of your function.

Aside: using uv_async_t.data like that is potentially unsafe. You
need proper synchronization (e.g. with a mutex) when multiple threads
access the .data field. Also, remember there is no 1-to-1
relationship between calls to uv_async_send() and your callback.

Stephen James

unread,
Apr 25, 2016, 5:27:34 PM4/25/16
to nodejs
Thanks that got me past that step. 
Reply all
Reply to author
Forward
0 new messages