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

pilight crashes at init connection #4

Closed
jmvermeulen opened this issue Dec 11, 2017 · 2 comments
Closed

pilight crashes at init connection #4

jmvermeulen opened this issue Dec 11, 2017 · 2 comments

Comments

@jmvermeulen
Copy link

Hello,

Im trying to integrate Home Assistant with pilight.
You lib is used bij HaSS to connect to the API. For some reason pilight daemon crashes when this lib connects to it. See https://forum.pilight.org/showthread.php?tid=3218 for more info.

With this sample code:

REQUIREMENTS = ['pilight==0.1.1']
from pilight import pilight

host = "127.0.0.1"
port = 5001

pilight_client = pilight.Client(host=host, port=port)

The debug output of pilight is:

[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

Is your lib compatible with version 8 of pilight?
And is there anything I can do to fix this issue?

@jmvermeulen
Copy link
Author

I'm sorry, it was the incorrect port..
Was using the HTTP endpoint as API, should have used port 5000 instead.

@DavidLP
Copy link
Owner

DavidLP commented Dec 18, 2017

Thank you for your bug report. Yes, the HTTP endpoint is not used by this python module. What you see is one of the bugs in the piligh library causing SEGFAULTS. Theoretically a SEGFAULT on the server side should never be triggered by a client message.
This bug is not the only error, depending on the string you send the pilight library reproducibly crashes. Fortunately this python module allows you to send only "valid" strings, besides the new bug you have found now ;-) This cannot be fixed in this python module and is addressed in the pilight library here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants