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

example/index.js: Segmentation fault #47

Open
gmacario opened this issue Nov 18, 2019 · 3 comments
Open

example/index.js: Segmentation fault #47

gmacario opened this issue Nov 18, 2019 · 3 comments

Comments

@gmacario
Copy link

gmacario commented Nov 18, 2019

Reproduced on node-blueooth v1.2.6 running in a container

  • Official Docker image node:10.17
  • node v10.17.0
  • Debian GNU/Linux 9 (stretch)
root@1fe89f7b3fe0:/app/node_modules/node-bluetooth# node --version
v10.17.0
root@1fe89f7b3fe0:/app/node_modules/node-bluetooth# node example/index.js
Segmentation fault
root@1fe89f7b3fe0:/app/node_modules/node-bluetooth#
@gmacario gmacario changed the title SIGSEV in example/index.js example/index.js: Segmentation fault Nov 18, 2019
@gmacario
Copy link
Author

Rebuilt node-bluetooth with --debug and run gdb to rootcause SIGSEGV

node-gyp --debug configure rebuild
gdb node

Inside gdb

root@1fe89f7b3fe0:/app/node_modules/node-bluetooth# gdb node
GNU gdb (Debian 7.12-6) 7.12.0.20161007-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from node...done.
(gdb) run example/index.js
Starting program: /usr/local/bin/node example/index.js
warning: Error disabling address space randomization: Operation not permitted
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fe7ab5a2700 (LWP 861)]
[New Thread 0x7fe7aada1700 (LWP 862)]
[New Thread 0x7fe7aa5a0700 (LWP 863)]
[New Thread 0x7fe7a9d9f700 (LWP 864)]
[New Thread 0x7fe7a959e700 (LWP 865)]
[New Thread 0x7fe7aca2a700 (LWP 866)]
[New Thread 0x7fe7a895f700 (LWP 867)]
[New Thread 0x7fe793fff700 (LWP 868)]
[New Thread 0x7fe7937fe700 (LWP 869)]
[New Thread 0x7fe792ffd700 (LWP 870)]

Thread 9 "node" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fe793fff700 (LWP 868)]
0x0000000000b01210 in v8::HandleScope::Initialize(v8::Isolate*) ()
(gdb) bt
#0  0x0000000000b01210 in v8::HandleScope::Initialize(v8::Isolate*) ()
#1  0x00007fe7a8b944b5 in Nan::HandleScope::HandleScope (this=0x7fe793ffecf0) at ../node_modules/nan/nan.h:429
#2  0x00007fe7a8b9471c in Nan::ThrowError (msg=0x7fe7a8b98f39 "opening socket") at ../node_modules/nan/nan.h:864
#3  0x00007fe7a8b9367f in DeviceINQ::doInquire () at ../src/linux/DeviceINQ.cc:184
#4  0x00007fe7a8b9550e in InquireWorker::Execute (this=0x363f5d0) at ../src/linux/DeviceINQ.cc:270
#5  0x00007fe7a8b94ee3 in Nan::AsyncExecute (req=0x363f5d8) at ../node_modules/nan/nan.h:2284
#6  0x0000000000a6ab3e in worker (arg=0x0) at ../deps/uv/src/threadpool.c:122
#7  0x00007fe7ab9494a4 in start_thread (arg=0x7fe793fff700) at pthread_create.c:456
#8  0x00007fe7ab68bd0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97
(gdb)

Inspecting local variables around https://github.com/song940/node-bluetooth/blob/master/src/linux/DeviceINQ.cc#L184

(gdb) up
#1  0x00007fe7a8b944b5 in Nan::HandleScope::HandleScope (this=0x7fe793ffecf0) at ../node_modules/nan/nan.h:429
429       inline HandleScope() : scope(v8::Isolate::GetCurrent()) {}
(gdb) up
#2  0x00007fe7a8b9471c in Nan::ThrowError (msg=0x7fe7a8b98f39 "opening socket") at ../node_modules/nan/nan.h:864
864       X(Error)
(gdb) up
#3  0x00007fe7a8b9367f in DeviceINQ::doInquire () at ../src/linux/DeviceINQ.cc:184
184         Nan::ThrowError("opening socket");
(gdb) p dev_id
$1 = -1
(gdb) p sock
$2 = -1
(gdb)

@gmacario
Copy link
Author

Checking the installed version of libbluetooth

root@1fe89f7b3fe0:/app/node_modules/node-bluetooth# dpkg -l | grep blue
ii  libbluetooth-dev                   5.43-2+deb9u1                  amd64        Development files for using the BlueZ Linux Bluetoo
th library
ii  libbluetooth3:amd64                5.43-2+deb9u1                  amd64        Library to use the BlueZ Linux Bluetooth stack
root@1fe89f7b3fe0:/app/node_modules/node-bluetooth#

@fossejc
Copy link

fossejc commented Jan 23, 2020

Hi all, I encounter the same issue with node-bluetooth running in a container

@gmacario where you able to find a solution ?

Thanks for your help.

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

No branches or pull requests

2 participants