lopter / lightsd

A daemon with a JSON-RPC API to control your light bulbs
GNU General Public License v3.0
129 stars 15 forks source link

lightsd crash when refreshing state from bulb #29

Open Magicking opened 6 years ago

Magicking commented 6 years ago

When using the python client to get light state, the lightsd daemon segfault, here is the traceback:

ipython shell using lightsc.py

>>> c.get_light_state("*")

Lightsd:

[2018-07-15T18:54:41.169086+02:00] [DEBUG] lightsd: scheduling next GET_LIGHT_STATE on [::ffff:192.168.0.20]:56700 in 800ms                                                                                        
[2018-07-15T18:54:41.169151+02:00] [DEBUG] lightsd: SET_LIGHT_STATE <-- [::ffff:192.168.0.19]:56700 - d0:73:d5:24:XX:XX hue=0, saturation=0, brightness=0xffff, kelvin=3500, dim=0, power=0, label=couloir2, tags=0
[2018-07-15T18:54:41.169191+02:00] [DEBUG] lightsd: [::ffff:192.168.0.19]:56700 GET_LIGHT_STATE for all bulbs on this gw has already been enqueued                                                                 
[2018-07-15T18:54:41.169227+02:00] [DEBUG] lightsd: SET_LIGHT_STATE <-- [::ffff:192.168.0.19]:56700 - d0:73:d5:24:XX:XX hue=0, saturation=0, brightness=0xffff, kelvin=3500, dim=0, power=0, label=couloir2, tags=0
[2018-07-15T18:54:41.169262+02:00] [DEBUG] lightsd: [::ffff:192.168.0.19]:56700 GET_LIGHT_STATE for all bu[2018-07-15T18:54:41.169227+02:00] [DEBUG] lightsd: SET_LIGHT_STATE <-- [::ffff:192.168.0.19]:56700 - d0:73:d5:XX:XX hue=0, saturation=0, brightness=0xffff, kelvin=3500, dim=0, power=0, label=couloir2, tags=0
[2018-07-15T18:54:41.169262+02:00] [DEBUG] lightsd: [::ffff:192.168.0.19]:56700 GET_LIGHT_STATE for all bulbs on this gw has already been enqueued
[2018-07-15T18:54:41.169391+02:00] [DEBUG] lightsd: SET_LIGHT_STATE <-- [::ffff:192.168.0.20]:56700 - d0:73:d5:25:XX:XX hue=0, saturation=0, brightness=0xffff, kelvin=3500, dim=0, power=0xffff, label=salon, tags=0
[2018-07-15T18:54:41.169474+02:00] [DEBUG] lightsd: [::ffff:192.168.0.20]:56700 GET_LIGHT_STATE for all bulbs on this gw has already been enqueued
[2018-07-15T18:54:41.169511+02:00] [DEBUG] lightsd: SET_LIGHT_STATE <-- [::ffff:192.168.0.20]:56700 - d0:73:d5:25:XX:XX hue=0, saturation=0, brightness=0xffff, kelvin=3500, dim=0, power=0xffff, label=salon, tags=0
[2018-07-15T18:54:41.169549+02:00] [DEBUG] lightsd: [::ffff:192.168.0.20]:56700 GET_LIGHT_STATE for all bulbs on this gw has already been enqueued

Program received signal SIGSEGV, Segmentation fault.
0x000055555555fb8b in jsmn_alloc_token ()
(gdb) bt
#0  0x000055555555fb8b in jsmn_alloc_token ()
#1  0x00005555555600ca in jsmn_parse ()
#2  0x000055555555c5f5 in lgtd_client_read_callback ()                                                   
#3  0x00007ffff7bb7d82 in ?? () from /usr/lib/libevent_core-2.1.so.6                                     
#4  0x00007ffff7bbd848 in ?? () from /usr/lib/libevent_core-2.1.so.6                                     
#5  0x00007ffff7bbe28f in event_base_loop () from /usr/lib/libevent_core-2.1.so.6                        
#6  0x000055555556557f in main ()
(gdb)
lopter commented 6 years ago

Oh, that's really strange, was this an isolated event or something you are able to reproduce?

Magicking commented 6 years ago

I could reproduce this every time, the setup was 5 bulbs (4 identical) on the same WiFi and the build was https://github.com/lopter/lightsd/commit/9f976a67e2d0214dba13c8eef88aec9fb57db6fb

lopter commented 6 years ago

Have you tried to get some more info with a debug build? (cmake -DCMAKE_BUILD_TYPE=DEBUG …).

etenim commented 5 years ago

I encountered this as well after re-compiling lightsd binary with newer gcc, glibc and more. Basically a more updated Linux OS overall. The hardware it runs on remained the same as always, it's just the software bits that are updated. Reverting to a lightsd binary compiled with older tools worked again.

Seeing as these two binaries I tried were built from the same source/version of lightsd, there seems to be some issue with lightsd when compiled with modern tools.

@lopter have you tried building lightsd with gcc 8? glibc 2.27 or 2.28? The latest libevent on my system is 2.1.8 and the latest cmake is 3.9.6.