Hexagon / node-telldus

Node bindings for telldus-core
Other
34 stars 10 forks source link

nodejs segfault error 15 in libuv.so.1.0.0 #74

Open Z3TA opened 7 years ago

Z3TA commented 7 years ago

I get this a lot, like every 30 minute or so when using the NodeJS tulldus module.

$ sudo journalctl --since="2016-11-09 14:43:00" | grep segfault -B 3

Nov 09 15:16:43 Z-MAINFRAME nodejs[4028]: 2016-11-09 (15:16:43_611 debug: sensorEvent: deviceId=135, protocol=temperaturehumidity, model=fineoffset, type=1 value=4.7, timestamp=1478701003 Nov 09 15:16:43 Z-MAINFRAME nodejs[4028]: [206B blob data] Nov 09 15:16:43 Z-MAINFRAME kernel: show_signal_msg: 91 callbacks suppressed Nov 09 15:16:43 Z-MAINFRAME kernel: nodejs[4028]: segfault at 7fcfab5708e0 ip 00007fcfab5708e0 sp 00007ffe65ab9ae8 error 15 in libuv.so.1.0.0[7fcfab570000+1000]

Nov 09 15:23:27 Z-MAINFRAME nodejs[4951]: 2016-11-09 (15:23:27_147 debug: sensorEvent: deviceId=151, protocol=temperaturehumidity, model=fineoffset, type=2 value=87, timestamp=1478701407 Nov 09 15:23:27 Z-MAINFRAME nodejs[4951]: [208B blob data] Nov 09 15:23:32 Z-MAINFRAME nodejs[4951]: 2016-11-09 (15:23:32_517 debug: RAW: class:sensor;protocol:fineoffset;id:183;model:temperaturehumidity;humidity:23;temp:20.6; Nov 09 15:23:32 Z-MAINFRAME kernel: nodejs[4951]: segfault at 7f889bdcd8e0 ip 00007f889bdcd8e0 sp 00007ffe4201cbe8 error 15 in libuv.so.1.0.0[7f889bdcd000+1000]

Nov 09 15:28:59 Z-MAINFRAME nodejs[5607]: 2016-11-09 (15:28:59_232 debug: RAW: class:sensor;protocol:fineoffset;id:167;model:temperaturehumidity;humidity:25;temp:20.7; Nov 09 15:28:59 Z-MAINFRAME nodejs[5607]: 2016-11-09 (15:28:59_233 debug: sensorEvent: deviceId=167, protocol=temperaturehumidity, model=fineoffset, type=1 value=20.7, timestamp=1478701739 Nov 09 15:28:59 Z-MAINFRAME nodejs[5607]: [208B blob data] Nov 09 15:28:59 Z-MAINFRAME kernel: nodejs[5607]: segfault at 7fe826a7c8e0 ip 00007fe826a7c8e0 sp 00007ffe0a2adb48 error 15 in libuv.so.1.0.0[7fe826a7c000+1000]

Nov 09 15:30:11 Z-MAINFRAME nodejs[6177]: [206B blob data] Nov 09 15:30:11 Z-MAINFRAME nodejs[6177]: 2016-11-09 (15:30:11_684 debug: sensorEvent: deviceId=199, protocol=temperaturehumidity, model=fineoffset, type=2 value=71, timestamp=1478701811 Nov 09 15:30:11 Z-MAINFRAME nodejs[6177]: [206B blob data] Nov 09 15:30:11 Z-MAINFRAME kernel: nodejs[6177]: segfault at 7fd217d8c8e0 ip 00007fd217d8c8e0 sp 00007ffd5768c5e8 error 15 in libuv.so.1.0.0[7fd217d8c000+1000]

Nov 09 15:31:49 Z-MAINFRAME nodejs[6456]: 2016-11-09 (15:31:49_909 debug: RAW: class:command;protocol:sartano;model:codeswitch;code:0110111000;method:turnon; Nov 09 15:31:50 Z-MAINFRAME nodejs[6456]: 2016-11-09 (15:31:50_56 debug: RAW: class:command;protocol:arctech;model:selflearning;house:15274990;unit:10;group:0;method:turnoff; Nov 09 15:31:50 Z-MAINFRAME nodejs[6456]: 2016-11-09 (15:31:50_57 debug: RAW: class:command;protocol:sartano;model:codeswitch;code:0110111000;method:turnon; Nov 09 15:31:50 Z-MAINFRAME kernel: nodejs[6456]: segfault at 7f5a1a9398e0 ip 00007f5a1a9398e0 sp 00007ffedaba0118 error 15 in libuv.so.1.0.0[7f5a1a939000+1000]

Nov 09 15:52:35 Z-MAINFRAME nodejs[6773]: [206B blob data] Nov 09 15:52:43 Z-MAINFRAME nodejs[6773]: 2016-11-09 (15:52:43_614 debug: sensorEvent: deviceId=135, protocol=temperaturehumidity, model=fineoffset, type=1 value=4.7, timestamp=1478703163 Nov 09 15:52:43 Z-MAINFRAME nodejs[6773]: [206B blob data] Nov 09 15:52:43 Z-MAINFRAME kernel: nodejs[6773]: segfault at 7f51a67c78e0 ip 00007f51a67c78e0 sp 00007fff2fd76818 error 15 in libuv.so.1.0.0[7f51a67c7000+1000]

Nov 09 15:57:23 Z-MAINFRAME nodejs[8580]: 2016-11-09 (15:57:23_676 debug: RAW: class:sensor;protocol:fineoffset;id:199;model:temperaturehumidity;humidity:71;temp:5.9; Nov 09 15:57:23 Z-MAINFRAME nodejs[8580]: 2016-11-09 (15:57:23_677 debug: sensorEvent: deviceId=199, protocol=temperaturehumidity, model=fineoffset, type=1 value=5.9, timestamp=1478703443 Nov 09 15:57:23 Z-MAINFRAME nodejs[8580]: [206B blob data] Nov 09 15:57:23 Z-MAINFRAME kernel: nodejs[8580]: segfault at 7f9c7f5108e0 ip 00007f9c7f5108e0 sp 00007ffc73143048 error 15 in libuv.so.1.0.0[7f9c7f510000+1000]

$ sudo apt-get install telldus-core telldus-core is already the newest version (2.1.2-1).

$ npm version { telldus: '1.1.0', npm: '3.5.2', ares: '1.10.1-DEV', http_parser: '2.5.0', icu: '55.1', modules: '46', node: '4.2.6', openssl: '1.0.2g-fips', uv: '1.8.0', v8: '4.5.103.35', zlib: '1.2.8' }

$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 16.04.1 LTS Release: 16.04 Codename: xenial

FlippAre commented 7 years ago

Experiencing the same problem after adding a temperature/humidity sensor to my setup

Hexagon commented 7 years ago

@Z3TA

Hmm, hmm hmm. I'm running almost exactly the same setup with no segfaults. I use a more recent node version, but have used the 4.x branch earlier without problems.

Even though this is obviously a bug in node-telldus, maybe a look at you code can give us a clue what's going wrong? It would be very helpful if i could reproduce the issue on my end.

Another question, have you upgraded node without rebuilding this module?


robin@core:~$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 16.04.1 LTS Release: 16.04 Codename: xenial

robin@core:~$ npm version { npm: '3.10.3', ares: '1.10.1-DEV', http_parser: '2.7.0', icu: '57.1', modules: '48', node: '6.3.1', openssl: '1.0.2h', uv: '1.9.1', v8: '5.0.71.57', zlib: '1.2.8' }

robin@core:~$ sudo apt-get install telldus-core telldus-core is already the newest version (2.1.2-1).

FlippAre commented 7 years ago

For me it's after adding a sensor event listener: https://github.com/ThinkFlipp/homebridge-telldus-tdtool/blob/temperature-sensor/src/lib/telldus-temperature.js#L59

Running latest Node and just rebuild the model. Will see if that will help

Hexagon commented 7 years ago

@ThinkFlipp Great, let me now if the rebuild makes any difference. Can't see anything wrong with your implementation.

I just created a torture-test (multiple event listeners with wierd actions) which I'll leave running until tomorrow. Hopefully i can reproduce it, and narrow it down from there.

Hexagon commented 7 years ago

@Z3TA @ThinkFlipp

Progress, requesting a single sensoreventlisterer seem safe (a test has been running without a problem since yesterday), but if you reqest multiple event-listeners the probability of segfault increases tremendously. I created a simple application with nine sensor event listeners, That segfaults within a couple of minutes.

So as a first step, try to use one single event listener which route the messages to the appropriate functions.

My own implementation as well as node-red-contrib-tellstick uses only one listener per type, that should explain why I've never ran into the problem before.

I will have a quick look if i can isolate the cause in the C-code, but cannot guarantee a fix right now.

Bottom line, it's currently not safe to register more than one event listener of each type.

FlippAre commented 7 years ago

@Hexagon Nice! I have had my setup running for about 24hours, with latest node and rebuilt lib, and with just one listener running. Still experiencing a few segfaults, but much fewer.

Z3TA commented 7 years ago

I've solved it by a module that forks a middle-man that communicates with node-telldus and respawn it when it crashes.

plastbox commented 7 years ago

Just wanted to add my two cents. I've got a simple program running with one event listener per type, and my application segfaulted after running for a little over 12 hours. journalctl returns:

Feb 21 00:41:28 serverbox kernel: node[16596]: segfault at 21c2a60 ip 00000000021c2a60 sp 00007ffead809978 error 15

I could throw together a workaround where node-telldus was used in it's own process launched by my application, and all events and commands were proxied through stdio, but if you could fix it I'd be much obliged.

For the record: $ node --version v7.5.0

$ npm --version 4.1.2

$ npm list └── telldus@1.1.2

Thanks!

Edit: further info. The software has managed to cause two segfaults since I originally posted this message. journalctl has the following to say: Feb 21 09:38:49 serverbox kernel: node[19237]: segfault at 21c2a60 ip 00000000021c2a60 sp 00007ffc71b9ec98 error 15

Feb 21 10:48:49 serverbox kernel: node[19546]: segfault at 21c2a60 ip 00000000021c2a60 sp 00007ffc8c74f418 error 15

Edit2: Feb 21 11:03:28 serverbox kernel: node[19755]: segfault at 21c2a60 ip 00000000021c2a60 sp 00007ffc916b80e8 error 15

Feb 22 11:34:12 serverbox kernel: node[22093]: segfault at 21c2a60 ip 00000000021c2a60 sp 00007fffd6a67f38 error 15

The software segfaults more than once per hour on a fresh Ubuntu Server 16.04 installation with the newest node and npm versions, with only my script running as a user initiated process.

Arkkimaagi commented 7 years ago

I'm having a segfault problem too, with only one listener for sensor events and one for device events.

@Z3TA any tips on how I could build a similar middleman solution?

Z3TA commented 7 years ago

@Arkkimaagi I've uploaded my middleman solution: https://github.com/Z3TA/tellcage

Arkkimaagi commented 7 years ago

Thanks @Z3TA, I'll have to take a look at it home. Seems great. I personally do not need the raw events, so I'll have to modify it a bit tho.