[Libwebsockets] R: Segmentation fault on Raspberry

Stefano Mora stefano.mora at newdep.com
Mon Aug 24 18:22:44 CEST 2020


Thanks,
in my code I have the following:

/* notice we allowed for LWS_PRE in the payload already */
m = lws_write(wsi, (unsigned char*)pmsg->payload + LWS_PRE, pmsg->len, LWS_WRITE_TEXT);
if (m < (int)pmsg->len) {
lwsl_err("[wc] WRITEABLE ERROR: ret %d lws_writing to ws\n", m);
return -1;
}

I added some debug string in the log and I discovered that a payload buffer was null  🙁

...
[2020/08/24 18:15:49:5937]  Firmware - pckt len=5 - 00 02 01 28 54
+send
0x68dfc 0x68c78 - 0x688a8
-send
WRITEABLE pss=0x68c78 pmsg:0x68c90 idxMsg:0 payload:0x68500
lws_issue_raw: ssl_capable_write (31) says 31

[2020/08/24 18:16:01:1145]  Firmware - pckt len=5 - 00 02 01 28 54
+send
0x68dfc 0x68c78 - 0x688a8
-send
WRITEABLE pss=0x68c78 pmsg:0x68c90 idxMsg:0 payload:0x68500
lws_issue_raw: ssl_capable_write (31) says 31

lws_validity_cb: wsi 0x688a8: scheduling validity check
rops_handle_POLLOUT_ws: issuing ping on wsi 0x688a8: ws lws-minimal h2: 0
lws_issue_raw: ssl_capable_write (2) says 2
WRITEABLE pss=0x68c78 pmsg:0x68c90 idxMsg:0 payload:0x68500
lws_issue_raw: ssl_capable_write (31) says 31
WRITEABLE pss=0x68c78 pmsg:0x68c98 idxMsg:1 payload:(nil)

Something is triggering the LWS_CALLBACK_SERVER_WRITEABLE twice, the first one with 2 bytes (?) and the second one with a null payload ..

Thanks!

Stefano



________________________________
Da: Andy Green <andy at warmcat.com>
Inviato: lunedì 24 agosto 2020 17:57
A: Stefano Mora <stefano.mora at newdep.com>; libwebsockets at ml.libwebsockets.org <libwebsockets at ml.libwebsockets.org>
Oggetto: Re: [Libwebsockets] Segmentation fault on Raspberry



On 8/24/20 4:55 PM, Stefano Mora wrote:

Isn't this -->

> #1  0xb6f43f60 in lws_write (wsi=0x688a8, buf=0x10 <error: Cannot access memory at address 0x10>,
>      len=0, wp=LWS_WRITE_TEXT) at /home/pi/libwebsockets/lib/core-net/output.c:269
> #2  0x0001ca24 in wsCallback(lws*, lws_callback_reasons, void*, void*, unsigned int) ()

telling us that you are calling, in your wsCallback() implementation,
lws_write() with buf set to 0x10 (ie, NULL + 0x10)?

-Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20200824/f218beaa/attachment.htm>


More information about the Libwebsockets mailing list