You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Under Node 10.12, calling the Call method of a Nan::Callback object returns a garbage object that appears to have been prematurely garbage collected. I have put together a toy extension that demonstrates this:
main.cc:
#include<node.h>
#include<nan.h>NAN_METHOD(RunCallback) {
if (!info[0]->IsFunction()) {
returnNan::ThrowTypeError("Argument must be function");
}
Nan::Callback *callback = newNan::Callback(v8::Local<v8::Function>::Cast(info[0]));
int argc = 0;
v8::Local<v8::Value> argv[argc] = {};
v8::Local<v8::Value> result = callback->Call(argc, argv);
if (result->IsNumber()) {
info.GetReturnValue().Set(Nan::True());
} else {
info.GetReturnValue().Set(Nan::False());
}
}
voidinit(v8::Local<v8::Object> exports) {
Nan::Set(exports, Nan::New("runCallback").ToLocalChecked(),
Nan::GetFunction(Nan::New<v8::FunctionTemplate>(RunCallback)).ToLocalChecked());
}
NODE_MODULE(callback_test, init);
Running index.js with Node 10.11 correctly outputs "true", and running it with Node 10.12 causes a segmentation fault in result->IsNumber(). The code works correctly under Node 10.12 if the callback->Call line is replaced with
Under Node 10.12, calling the
Call
method of aNan::Callback
object returns a garbage object that appears to have been prematurely garbage collected. I have put together a toy extension that demonstrates this:main.cc:
index.js:
binding.gyp:
Running
index.js
with Node 10.11 correctly outputs "true", and running it with Node 10.12 causes a segmentation fault inresult->IsNumber()
. The code works correctly under Node 10.12 if thecallback->Call
line is replaced withThe text was updated successfully, but these errors were encountered: