-
Notifications
You must be signed in to change notification settings - Fork 462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reference count of ObjectWrap changed in Node.js 14.17.0 #998
Comments
@oyyd can you share the core dump backtrace in your realm programs? (you can wipe out sensitive data from the text backtrace) It will be helpful to track down the problem since you said the code snippet doesn't crash. |
@legendecas The backtrace is:
Although I didn't build a debug version of Node.js to inspect the coredump file, the code that aborts inside |
@legendecas I forgot to enable cpp exceptions. The code snippet also aborts when cpp exceptions enabled. |
I believe it is this commit nodejs/node@03806a0#diff-4b35cbf831be523a4f3e5aac3729c95490ed220892695d0e4245c15c1f63cfc1R278 making the problem prominent. Although this crash is introduced in a newer version of Node.js, the first impression came to me that this is a user code bug in terms of API semantics. Calling The value |
I call #include <napi.h>
class MyObject : public Napi::ObjectWrap<MyObject> {
public:
static Napi::Object Init(Napi::Env env, Napi::Object exports);
MyObject(const Napi::CallbackInfo& info);
~MyObject();
};
Napi::Object MyObject::Init(Napi::Env env, Napi::Object exports) {
Napi::Function func =
DefineClass(env,
"MyObject",
{});
Napi::FunctionReference* constructor = new Napi::FunctionReference();
*constructor = Napi::Persistent(func);
env.SetInstanceData(constructor);
exports.Set("MyObject", func);
return exports;
}
MyObject::MyObject(const Napi::CallbackInfo& info)
: Napi::ObjectWrap<MyObject>(info) {
this->Ref();
}
MyObject::~MyObject() {
// comment these lines
// uint32_t count = -1;
// count = this->Unref();
// fprintf(stderr, "count %d\n", count);
}
Napi::Object InitAll(Napi::Env env, Napi::Object exports) {
return MyObject::Init(env, exports);
}
NODE_API_MODULE(addon, InitAll) get:
|
@oyyd can you share the build configuration and Node.js version when not calling |
@legendecas Please see this example https://github.com/oyyd/addon_abort_example. Thanks for your patient investigation:) |
@oyyd sorry about the delay but your example did call |
This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made. |
Not sure if this is an issue of
napi
ornode-addon-api
, but we found this when usingnode-addon-api
so I post it here.The code below:
Running the code in Node.js 14.16 will get:
In Node.js 14.17, the result becomes:
Though the code snippet doesn't throw here, in our real programs, running similar codes in Node.js 14.17 causes:When enable cpp exceptions i.e.
NAPI_CPP_EXCEPTIONS
, run the script will result in:The text was updated successfully, but these errors were encountered: