notjosh / bleno-mac

Bleno MacOS bindings using the official CoreBluetooth API
MIT License
23 stars 24 forks source link

Segmentation Fault 11 Error #12

Closed martinabrahams closed 4 years ago

martinabrahams commented 4 years ago

Hi, I've been trying to get this to work for days. I'm running;

When I run a simple echo example I get a segfault 11 error, this error occures regardless of whether I have Bluetooth enabled or disabled. I have attached the relevant system log.

The error appears to relate to the native bindings - BlenoMac::Init(Napi::CallbackInfo const&) + 133 (bleno_mac.mm:52)

I've created a repo to replicate my issue.

stack-trace.txt

jhays commented 4 years ago

I also saw this segmentation fault 11 error when trying to run some bleno related code from a Mac on 10.15.2.

I have since uninstalled and reinstalled bleno-mac, and now when I try to run node service.js, the terminal just hangs there and prints out nothing until I stop with ctrl-c.

So I can no longer reproduce the segmentation fault 11 issue, but I did see that occur this morning before I uninstalled/reinstalled the package.

jhays commented 4 years ago

Bumping this- Anyone have any thoughts on the status of bleno-mac on macOS 10.15.2 ?

I tried using this again and I'm still seeing the terminal hang when I try to run bleno service code via node.

dysquard commented 4 years ago

Bumping this- Anyone have any thoughts on the status of bleno-mac on macOS 10.15.2 ?

I tried using this again and I'm still seeing the terminal hang when I try to run bleno service code via node.

Exactly same here. Before it's seg fault 11 and after I deleted the node_modules and did npm install it just stuck at bleno - echo.

manpreetnarang commented 4 years ago

+1 having the same error, it's working on 10.14 but it's not working working on 10.15.2

ankit2002 commented 4 years ago

I am also getting the segmentation fault on 10.15.4.

koush commented 4 years ago

Rusty on my obj-c but the fix was straightforward. Starting the bluetooth manager immediately starts firing status events, before the event emitter has been properly initialized. Race condition.

https://github.com/notjosh/bleno-mac/pull/13

koush commented 4 years ago

I also had to fork this repository and updated bleno dependency to use the following in package.json:

   "bleno": "abandonware/bleno",

Otherwise it won't compile at all with recent node versions.

kotsaarev commented 4 years ago

Hello, I came from Punch Through’s article and I tried to use the "bleno-mac" as dependency. It was a fail.

My initial config was

I tried to use node v10 and v12 also, but it was an issue with xpc-connection

...
../src/XpcConnection.cpp:143:89: error: too few arguments to function call, expected 2,
      have 1
...
5 warnings and 1 error generated.
make: *** [Release/obj.target/binding/src/XpcConnection.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:191:23)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Darwin 19.4.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/kotsarev/src/bleno/node_modules/xpc-connection
gyp ERR! node -v v10.20.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
...

Also I tried to use @abandonware/bleno, but I got stuck in terminal after run node service.

Finally, this advice was useful to me.

Hopefully, I'll save someone some time.

jhays commented 4 years ago

Hi @kotsaarev, I work at PunchThrough and happen to be the author of that article-

I have not had an opportunity to test bleno-mac yet since this issue was addressed yesterday, but as you've discovered it looks like there is an issue with xpc-connection as well.

I will need to add an update to my article to help anyone trying to use this on the latest macOS. Thanks for sharing the solution you have found.