• 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
][solved]Segfault when retrieving big chunked http message
#11
Thanks for reporting, i will investigate as soon as i have time.
 
Reply
#12
I understand. I was thinking of making a fix for myself for the meantime, but if you wish I could post my fix after testing it myself.

My idea was to search for \r\n\r\n and then interpret all preceding characters on the line as an unsigned long number. If that number is 0 (zero) than it is the sequence terminating the chunked transfer.

EDIT: I should have read the doumentation better and overlooked the endptr parameter. Blush

But strtoul() cannot be used for this, because that also returns a zero if the characters would not be representing a number. There is little chance that that ever will happen with a decent website, but to be sure I think it must be done in a different way.

Therefor I am thinking of just scanning al characters preceeding the "\r\n\r\n" and check if they are all "0".
 
Reply
#13
Any update on this issue? I am running pilight 1.8.3 and the http.lua from A couple of months ago having issues with random crashes of pilight.
 
Reply
#14
@curlymo made a fix in lua.c some time ago. Did you update?

In my case I still had occasional segfaults directly after that update, but I didn't see any segfault over the last three weeks! Maybe I had some corruption on my RPi?

So, if you didn't yet update, do it now and please report your experiences then. If it solves the segfaults you got too, the issue can be considered as solved.
 
Reply
#15
If tested your example, but it doesn't segfault:
Code:
code: 200
size: 331
type: text/html
data:
Sending data chunk 1 of 10 <br />Sending data chunk 2 of 10 <br />Sending data chunk 3 of 10 <br />Sending data chunk 4 of 10 <br />Sending data chunk 5 of 10 <br />Sending data chunk 6 of 10 <br />Sending data chunk 7 of 10 <br />Sending data chunk 8 of 10 <br />Sending data chunk 9 of 10 <br />Sending data chunk 10 of 10 <br />

Code:
http_get_content("http://www.mariniek.com/test_chunked/", callback, NULL);
 
Reply
#16
It looks like you did not read my previous posts in this thread. Smile I wrote that I did not get any segfaults over the last three weeks. So it doesn't surprise me that you didn't get a segfault.

By now, I am assuming that the segfaults I got after your fix in lua.c were not caused by pilight.  Although I am not 100% sure, because there were rather long periods between the segfaults before.

The other issue I reported was that a chunked response is not handled correctly and always fails with a 408 code. That is what can be tested with my website.

Already I made a fix by replacing the (3) checks in http.c for 0\r\n\r\n to find the end of a chunked transfer by a function call that checks if \0\r\\n\r\n\ is at the end of the buffer and is not preceeded by any character other than  "0". With this fix all chunked responses are now finishing properly for me.
 
Reply
#17
The issue that some chunked responses always return 408 is also what i replied to. Hence the full callback output. The response code i got was just 200 instead of the 408. And that was using your website.
 
Reply
#18
Well that's strange. I have to investigate.
 
Reply
#19
At the moment I am puzzled. Here the request consistently fails with 408.

Code:
[Nov 29 09:24:21:858249] pilight-daemon: ERROR: /usr/local/lib/pilight/actions/http.lua:121: http action calling http://www.mariniek.com/test_chunked/ failed with code 408

I will do a fresh clone and reinstall from staging first and see if I still can reproduce it then.
 
Reply
#20
I will check again tonight.
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  [SOLVED] Triggering generic_switch leads to segfault Ulrich.Arnold 19 906 10-23-2019, 09:03 AM
Last Post: Ulrich.Arnold
  http code 301 causes segfault Niek 3 3,355 08-14-2018, 06:57 PM
Last Post: curlymo
  no callback on some http requests Niek 20 6,512 07-28-2018, 10:22 AM
Last Post: Niek
  http library doesn't properly handle big response Niek 39 6,972 07-17-2018, 07:26 PM
Last Post: curlymo
  Long label text causes segfault Niek 10 1,378 06-29-2018, 02:18 PM
Last Post: Niek
  [Solved] config.json not updated Niek 6 1,535 12-31-2017, 03:19 PM
Last Post: curlymo
  [Solved] callback not executing when dns lookup fails Niek 1 655 10-08-2017, 11:44 AM
Last Post: curlymo
  [Solved] Rules switching state based on another device state not working apartmedia 6 2,489 09-27-2017, 01:41 PM
Last Post: apartmedia
  [Solved] connection to main pilight daemon lost TopdRob 20 4,286 09-17-2017, 04:30 PM
Last Post: curlymo
  [Solved] dimmer protocol kaku_dimmer does not react on dimmervalue apartmedia 25 4,120 09-16-2017, 10:29 PM
Last Post: apartmedia

Forum Jump:


Browsing: 1 Guest(s)