node-ffi-napi/ref-napi

Check failed: result.second on Node.js v14.15.0

minggangw opened this issue · 8 comments

When I upgrade Node.js to the latest LTS v14.15.0, a fatal error happens when running the unit test, but it's ok with Node.js v12, please check out the error log below:

#
# Fatal error in , line 0
# Check failed: result.second.
#
#
#
#FailureMessage Object: 0x7fff04fd3a70
 1: 0xa70141  [node]
 2: 0x19cf084 V8_Fatal(char const*, ...) [node]
 3: 0xe594c9 v8::internal::GlobalBackingStoreRegistry::Register(std::shared_ptr<v8::internal::BackingStore>) [node]
 4: 0xba4a18 v8::ArrayBuffer::GetBackingStore() [node]
 5: 0x9c18f0 napi_get_typedarray_info [node]
 6: 0x7fa130ce70ef  [/root/rclnodejs/node_modules/ref-napi/prebuilds/linux-x64/node.napi.node]
 7: 0x7fa130ce7918  [/root/rclnodejs/node_modules/ref-napi/prebuilds/linux-x64/node.napi.node]
 8: 0x7fa130ce7bbb  [/root/rclnodejs/node_modules/ref-napi/prebuilds/linux-x64/node.napi.node]
 9: 0x7fa130cefceb Napi::details::CallbackData<void (*)(Napi::CallbackInfo const&), void>::Wrapper(napi_env__*, napi_callback_info__*) [/root/rclnodejs/node_modules/ref-napi/prebuilds/linux-x64/node.napi.node]
10: 0x9b8c8f  [node]
11: 0xbe369b  [node]
12: 0xbe4c46  [node]
13: 0xbe52c6 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [node]
14: 0x13ff259  [node]
Illegal instruction (core dumped)

For the detailed log, please see https://travis-ci.org/github/RobotWebTools/rclnodejs/builds/739832615

Thanks!

I found a similar issue from nodejs, please see nodejs/node#32463 @addaleax would you please help to have a look? Thanks!

@minggangw Without a smaller reproduction, I don’t think it’s going to be feasible for me to look into this in much detail

Thanks for your reply and I will try to narrow it down to find any useful clue.

@addalex Here's a script that breaks on macOS 11.0.1, using node 14.15.1 or 15.3.0. Works fine on node 12.

#!/usr/bin/env node

const ffi = require('ffi-napi');
const ref = require('ref-napi');
const ArrayType = require('ref-array-napi');

const lib = ffi.Library(null, {
    execvp: ['int', ['string', ArrayType('string')]],
    dup2: ['int', ['int', 'int']],
});

[process.stdin, process.stdout, process.stderr].forEach((x, i) => {
    lib.dup2(x._handle.fd, i);
});

lib.execvp('echo', ['', 'foo', ref.NULL]);

Trace:

#
# Fatal error in , line 0
# Check failed: result.second.
#
#
#
#FailureMessage Object: 0x7ffeefbfcd40
 1: 0x1001137c2 node::NodePlatform::GetStackTracePrinter()::$_3::__invoke() [/Users/foo/.nvm/versions/node/v14.15.1/bin/node]
 2: 0x10100e4f2 V8_Fatal(char const*, ...) [/Users/foo/.nvm/versions/node/v14.15.1/bin/node]
 3: 0x1004d4d44 v8::internal::GlobalBackingStoreRegistry::Register(std::__1::shared_ptr<v8::internal::BackingStore>) [/Users/foo/.nvm/versions/node/v14.15.1/bin/node]
 4: 0x1001fa9b6 v8::ArrayBuffer::GetBackingStore() [/Users/foo/.nvm/versions/node/v14.15.1/bin/node]
 5: 0x100069fce napi_get_typedarray_info [/Users/foo/.nvm/versions/node/v14.15.1/bin/node]
 6: 0x11112e6f8 (anonymous namespace)::WrapPointer(Napi::Env, char*, unsigned long) [/Users/foo/dev/...snip.../node_modules/ref-napi/prebuilds/darwin-x64/node.napi.node]
 7: 0x11112f2a9 (anonymous namespace)::ReadPointer(Napi::CallbackInfo const&) [/Users/foo/dev/...snip.../node_modules/ref-napi/prebuilds/darwin-x64/node.napi.node]
 8: 0x1046eb53f napi_value__* Napi::details::WrapCallback<Napi::details::CallbackData<Napi::Value (*)(Napi::CallbackInfo const&), Napi::Value>::Wrapper(napi_env__*, napi_callback_info__*)::'lambda'()>(Napi::Value (*)(Napi::CallbackInfo const&)) [/Users/foo/dev/...snip.../node_modules/ffi-napi/node_modules/ref-napi/prebuilds/darwin-x64/node.napi.node]
 9: 0x1046eb4dd Napi::details::CallbackData<Napi::Value (*)(Napi::CallbackInfo const&), Napi::Value>::Wrapper(napi_env__*, napi_callback_info__*) [/Users/foo/dev/...snip.../node_modules/ffi-napi/node_modules/ref-napi/prebuilds/darwin-x64/node.napi.node]
10: 0x10006360a v8impl::(anonymous namespace)::FunctionCallbackWrapper::Invoke(v8::FunctionCallbackInfo<v8::Value> const&) [/Users/foo/.nvm/versions/node/v14.15.1/bin/node]
11: 0x100259878 v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) [/Users/foo/.nvm/versions/node/v14.15.1/bin/node]
12: 0x100258e0c v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/Users/foo/.nvm/versions/node/v14.15.1/bin/node]
13: 0x100258532 v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/Users/foo/.nvm/versions/node/v14.15.1/bin/node]
14: 0x100a796d9 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit [/Users/foo/.nvm/versions/node/v14.15.1/bin/node]
15: 0x100a129a2 Builtins_InterpreterEntryTrampoline [/Users/foo/.nvm/versions/node/v14.15.1/bin/node]
[1]    50613 illegal hardware instruction  ./index.js

Folks, we too have run into this issue, any update on when this will be fixed pls?

Same here. Works in 12, but fails in 14 and 15.

Any update after more than a whole year?

There has been an update in #54, which I think is the same bug here, claiming that the bug is now fixed in Node 17.