Skip to content
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

segfault with node v12.19.0 #713

Closed
koonpeng opened this issue Oct 20, 2020 · 11 comments · Fixed by #740
Closed

segfault with node v12.19.0 #713

koonpeng opened this issue Oct 20, 2020 · 11 comments · Fixed by #740

Comments

@koonpeng
Copy link
Collaborator

rclnodejs segfaults after a few seconds after receiving a subscription. It only happens with node v12.19, works fine in v12.18.4.

To reproduce:

const rclnodejs = require('rclnodejs');

async function main() {
  await rclnodejs.init();
  const node = rclnodejs.createNode('test');
  rclnodejs.spin(node);
  
  node.createSubscription('std_msgs/msg/String', 'test', {}, console.log);

  const pub = node.createPublisher('std_msgs/msg/String', 'test');
  pub.publish({ data: 'hello' });
}

main();

Output:

$ node test.js 
{ data: 'hello' }
Segmentation fault (core dumped)
@minggangw
Copy link
Member

I noticed the same issue when I tried to upgrade the Node.js to v12.19 for the CI, and after checking the dump file, the backtrace shows no rclnodejs related callings. I suggest we could verify this on the next stable release of Node.js, how do you think?

@minggangw
Copy link
Member

I cannot reproduce it on v13.14.0

@koonpeng
Copy link
Collaborator Author

nodejs/node#35620 It looks like someone else has the same problem (I got the same stack trace).

@minggangw
Copy link
Member

I try the latest Node.js LTS v14.15.0 #716 and it seems that there is a crash caused by ref-napi, paste 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]

@koonpeng
Copy link
Collaborator Author

I got that as well, I think it's unrelated, it seems more like some v8 changes that causes it instead.

Btw, the offending commit that causes v12.19 to fail has been identified and I think they will be backporting the fix in the next release. I'll go ahead and close this issue.

@minggangw
Copy link
Member

Segmentation fault still happens on node v12.19.1 when running npm test

#0  0x00000000055001c0 in ?? ()
#1  0x0000000000d17c4b in v8::internal::GlobalHandles::InvokeSecondPassPhantomCallbacksFromTask() ()
#2  0x0000000000c953e3 in v8::internal::CancelableTask::Run() ()
#3  0x0000000000a86d54 in node::PerIsolatePlatformData::RunForegroundTask(std::unique_ptr<v8::Task, std::default_delete<v8::Task> >) ()
#4  0x0000000000a87a15 in node::PerIsolatePlatformData::FlushForegroundTasksInternal() ()
#5  0x000000000136f0ae in uv__async_io (loop=0x2cb3a80 <default_loop_struct>, w=<optimized out>, 
    events=<optimized out>) at ../deps/uv/src/unix/async.c:163
#6  0x0000000001382165 in uv__io_poll (loop=loop@entry=0x2cb3a80 <default_loop_struct>, 
    timeout=<optimized out>) at ../deps/uv/src/unix/linux-core.c:461
#7  0x000000000136f8ef in uv_run (loop=0x2cb3a80 <default_loop_struct>, mode=UV_RUN_DEFAULT)
    at ../deps/uv/src/unix/core.c:385
#8  0x0000000000a5aac6 in node::NodeMainInstance::Run() ()
#9  0x00000000009e85cc in node::Start(int, char**) ()
#10 0x00007f0ccfa3a0b3 in __libc_start_main (main=0x9804a0 <main>, argc=3, argv=0x7ffd273d8e98, 
    init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffd273d8e88)
    at ../csu/libc-start.c:308
#11 0x00000000009819b5 in _start ()

@koonpeng
Copy link
Collaborator Author

koonpeng commented Nov 17, 2020

@minggangw
Copy link
Member

Let's move to v14.x directly 😅

@koonpeng
Copy link
Collaborator Author

Actually v14 also segfaults

@minggangw
Copy link
Member

Yeah, indeed. It seems node.js is not stable enough :(

minggangw pushed a commit to minggangw/rclnodejs-1 that referenced this issue Nov 25, 2020
minggangw pushed a commit that referenced this issue Nov 25, 2020
@minggangw
Copy link
Member

The segfaults has been fixed on the latest v12.20.0 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants