• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pilight -> Home Assistant crash
#1
Hello,

Im trying to integrate pilight with Home Assistant.
Independently both are working fine.

But at the moment HA connects as a client to pilight the daemon crashes.
I've used the release 8.0.4, compiled the master branch and at last the development branch. All with the same result.

I've attached a debug session result, pilight seems to crash at a simple strcmp.
Can someone help me out here?

Im running the latest version of HA and on a RPI 2 and both applications are running on the RPI.

HA config:
Code:
pilight:
  host: 10.0.0.6
  port: 5001

pilight config (currently empty, have it working with devices as well):
Code:
{
    "devices": {},
    "rules": {},
    "gui": {},
    "settings": {
        "log-level": 6,
        "pid-file": "/var/run/pilight.pid",
        "log-file": "/var/log/pilight.log",
        "webserver-enable": 1,
        "webserver-root": "/usr/local/pilight/webgui",
        "webserver-http-port": 5001,
        "webserver-cache": 1,
        "gpio-platform": "none"
    },
    "hardware": {},
    "registry": {}
}

Code:
[Dec 09 20:39:35:338994] pilight-daemon: DEBUG: cpu: 0.076251%
[Dec 09 20:39:36:99890] pilight-daemon: DEBUG: new client, ip: 10.0.0.6, port: 33772
[Dec 09 20:39:36:100054] pilight-daemon: DEBUG: client fd: 17
[Dec 09 20:39:36:118482] pilight-daemon: DEBUG: new client, ip: 10.0.0.6, port: 33774
[Dec 09 20:39:36:118641] pilight-daemon: DEBUG: client fd: 18

Thread 1 "pilight-daemon" received signal SIGSEGV, Segmentation fault.
__GI_strcmp (p1=<optimized out>, p2=<optimized out>) at strcmp.c:38
38      strcmp.c: No such file or directory.
(gdb) backtrace
#0  __GI_strcmp (p1=<optimized out>, p2=<optimized out>) at strcmp.c:38
#1  0xb67c8c20 in request_handler (req=0x4b3b8) at /home/pi/repos/pilight/libs/pilight/core/webserver.c:892
#2  0xb67cba8c in client_read_cb (req=0x4b3b8, nread=0x4b7fc, buf=0x4b848 "{\"options\":") at /home/pi/repos/pilight/libs/pilight/core/webserver.c:1652
#3  0xb67abe54 in uv_custom_poll_cb (req=0x4b3b8, status=0, events=1) at /home/pi/repos/pilight/libs/pilight/core/eventpool.c:694
#4  0xb678a984 in uv__poll_io (loop=0xb6fa95f8 <default_loop_struct>, w=0x4b3ec, events=1) at /home/pi/repos/pilight/libs/libuv/unix/poll.c:64
#5  0xb6784224 in uv__io_poll (loop=0xb6fa95f8 <default_loop_struct>, timeout=2220) at /home/pi/repos/pilight/libs/libuv/unix/linux-core.c:400
#6  0xb677a8d8 in uv_run (loop=0xb6fa95f8 <default_loop_struct>, mode=UV_RUN_DEFAULT) at /home/pi/repos/pilight/libs/libuv/unix/core.c:362
#7  0x0001cb00 in main (argc=2, argv=0xbefff784) at /home/pi/repos/pilight-dev/pilight/daemon.c:3468
(gdb) frame 0
#0  __GI_strcmp (p1=<optimized out>, p2=<optimized out>) at strcmp.c:38
38      in strcmp.c
(gdb) frame 1
#1  0xb67c8c20 in request_handler (req=0x4b3b8) at /home/pi/repos/pilight/libs/pilight/core/webserver.c:892
892                             } else if(strcmp(&conn->uri[(rstrstr(conn->uri, "/")-conn->uri)], "/") == 0) {
(gdb) frame 2
#2  0xb67cba8c in client_read_cb (req=0x4b3b8, nread=0x4b7fc, buf=0x4b848 "{\"options\":") at /home/pi/repos/pilight/libs/pilight/core/webserver.c:1652
1652                    int x = request_handler(req);
(gdb) frame 3
#3  0xb67abe54 in uv_custom_poll_cb (req=0x4b3b8, status=0, events=1) at /home/pi/repos/pilight/libs/pilight/core/eventpool.c:694
694                                             custom_poll_data->read_cb(req, &custom_poll_data->recv_iobuf.len, custom_poll_data->recv_iobuf.buf);
(gdb) frame 4
 
Reply
#2
Can you print the content of conn->uri when debugging?
 
Reply
#3
(12-10-2017, 05:01 PM)curlymo Wrote: Can you print the content of conn->uri when debugging?

The value of conn->uri is "core" at the moment it crashes.

Btw, Home Assistant uses this lib for its communication with pilight:
https://github.com/DavidLP/pilight
 
Reply
#4
It's sound wierd to me that Home Assistent uses the webgui for it's communication, but the least i can do from the pilight side is making sure it doesn't crash. Will look into it.

Can you figure what the exact url is that is being retrieved?
 
Reply
#5
(12-10-2017, 08:40 PM)curlymo Wrote: It's sound wierd to me that Home Assistent uses the webgui for it's communication, but the least i can do from the pilight side is making sure it doesn't crash. Will look into it.

Can you figure what the exact url is that is being retrieved?

Is there another/better way to communicate with pilight with the same feature options?
I didn't look into what the external lib supports.

If there is a better way, maybe I can write a betters solution via a API?

I understand you cannot actively support the 3th party lib or Home Assistant, it would be great if you can make pilight not crash on this url.

Will try to resolve the exact URL that causes the issue.

Edit: I've also submitted a issue at the client lib.
https://github.com/DavidLP/pilight/issues/4
 
Reply
#6
Ok I'm a little ashamed..

The problem seems to be the port number.
I had configured the webserver port 5001, instead I should have used the api port 5000.

Tip to other users:
define the port in the pilight config:
"port": 5000

Now HaSS can connect at this fixed port.

Maybe the webserver can be fixed so it doesn't fully crash at a API request on its HTTP interface?
 
Reply
#7
What a great bug.
Code:
{"action":"identify","options":{"core":0,"receiver":1,"config":0,"forward":0}}
{"action": "identify", "options": {"core": 0, "receiver": 1, "config": 0, "forward": 0}}
The first one works, the second one fails. The spaces are what's triggering it. I will work on a fix the next few days.

https://github.com/pilight/pilight/commi...0d4577926f

Fixed and will be tested for in the future. I will port this to development -> staging -> master soon.
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  [Fixed] High CPU usage when pilight usb nano disconnects DieterK 1 91 08-13-2019, 05:43 PM
Last Post: curlymo
  pilight Nano USB interface curlymo 228 95,137 07-10-2019, 06:14 PM
Last Post: curlymo
  problems compiling pilight on Odroid C2 WitchDoctor 101 9,120 03-14-2019, 09:01 PM
Last Post: curlymo
  pilight 8 what chages for custom protocols? polo 11 2,767 02-15-2019, 06:22 PM
Last Post: polo
  Crash in 8.1.3 stable on Pi 3 kylex 25 1,922 11-16-2018, 02:05 PM
Last Post: kylex
  pilight-debug shows nothing minhdomanh 3 503 10-18-2018, 07:01 AM
Last Post: felfert
  pilight-send and pilight-daemon DieterK 0 528 06-20-2018, 12:44 AM
Last Post: DieterK
  Lights not switched on or off by rules in pilight 8.1.0 rorie 22 2,382 06-12-2018, 03:56 PM
Last Post: curlymo
  check API in pilight 8 stratege-0815 4 1,341 02-11-2018, 09:34 AM
Last Post: stratege-0815
  pilight-receive terminates zackdvd 8 1,572 12-30-2017, 09:07 PM
Last Post: curlymo

Forum Jump:


Browsing: 1 Guest(s)