Hi below code is crashing when i perform if check on argv[1]. Please help to fix it, while assigning the value to argv[1] i need to check if bool variable checktrue is true assign string value else assign int value as below code.
void DispatchEventWorker::HandleOKCallback() {
v8::Local<v8::Value> argv[2];
argv[0]= Nan::New<v8::String>(structdata.value1).ToLocalChecked();
if(checktrue)
{
argv[1] = Nan::New<v8::Number>(structdata.value2).ToLocalChecked();
}
else
{
argv[1] = Nan::New<v8::String>(structdata.value3);
}
callback->Call(2, argv);
}
Note output : Process 123432098 (node) terminated SIGSEGV code=1 fltno=11 ip=0000000001076a08(/usr/lib/ldqnx-64.so.2@memcpy+0x0000000000000048) mapaddr=0000000000076a08. ref=2073696874206f74
First, I suggest you always include the
async_resource
when calling back JS or otherwise some Node.js features won't work:Then, your code is missing a
.ToLocalChecked()
onargv[1]
and does not compile in its current form.Otherwise there is nothing fundamentally wrong with it and most probably the crash is not Node.js related - maybe one of these values is a null pointer.