[Libwebsockets] Segmentation fault on Raspberry

Stefano Mora stefano.mora at newdep.com
Mon Aug 24 17:55:13 CEST 2020


Hi all,
I'm porting the libwebsockets library on Raspberry 4 platform - Raspbian buster.
Sources of both application and library are identical to the ones on Tinkerboard I'm using without any problem.

On Raspberry after some minutes I observe the Segmentation fault: in the meantime my program is talking with a IO board via serial port; every 10 seconds I ask the firmware version and send the result to a web/javascript page.

This is what the terminal reports:

Program received signal SIGSEGV, Segmentation fault.
0xb6f73fe4 in rops_write_role_protocol_ws (wsi=0x688a8,
    buf=0x10 <error: Cannot access memory at address 0x10>, len=0, wp=0xbeffed48)
    at /home/pi/libwebsockets/lib/roles/ws/ops-ws.c:1784
1784                            buf[-pre] = n;
(gdb)
(gdb) bt
#0  0xb6f73fe4 in rops_write_role_protocol_ws (wsi=0x688a8,
    buf=0x10 <error: Cannot access memory at address 0x10>, len=0, wp=0xbeffed48)
    at /home/pi/libwebsockets/lib/roles/ws/ops-ws.c:1784
#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) ()
#3  0xb6f4e4fc in user_callback_handle_rxflow (
    callback_function=0x1c47c <wsCallback(lws*, lws_callback_reasons, void*, void*, unsigned int)>,
    wsi=0x688a8, reason=LWS_CALLBACK_SERVER_WRITEABLE, user=0x68c78, in=0x0, len=0)
    at /home/pi/libwebsockets/lib/core-net/wsi.c:303
#4  0xb6f4bc1c in lws_callback_as_writeable (wsi=0x688a8)
    at /home/pi/libwebsockets/lib/core-net/service.c:56
#5  0xb6f4bf60 in lws_handle_POLLOUT_event (wsi=0x688a8, pollfd=0x65500)
    at /home/pi/libwebsockets/lib/core-net/service.c:218
#6  0xb6f72fe4 in rops_handle_POLLIN_ws (pt=0x64030, wsi=0x688a8, pollfd=0x65500)
    at /home/pi/libwebsockets/lib/roles/ws/ops-ws.c:993
#7  0xb6f4ce88 in lws_service_fd_tsi (context=0x63ec8, pollfd=0x65500, tsi=0)
    at /home/pi/libwebsockets/lib/core-net/service.c:710
#8  0xb6f2c07c in _lws_plat_service_forced_tsi (context=0x63ec8, tsi=0)
    at /home/pi/libwebsockets/lib/plat/unix/unix-service.c:49
#9  0xb6f2c518 in _lws_plat_service_tsi (context=0x63ec8, timeout_ms=2000000000, tsi=0)
    at /home/pi/libwebsockets/lib/plat/unix/unix-service.c:207
#10 0xb6f2c598 in lws_plat_service (context=0x63ec8, timeout_ms=1000)
    at /home/pi/libwebsockets/lib/plat/unix/unix-service.c:221
#11 0xb6f4d070 in lws_service (context=0x63ec8, timeout_ms=1000)
    at /home/pi/libwebsockets/lib/core-net/service.c:777
#12 0x00014f2c in main ()


This is my log, the data returned is '{"cmd":"firmware","v":"1.40"}' :
...
[2020/08/24 17:22:40:3742]  Firmware - pckt len=5 - 00 02 01 28 54
+send
-send
lws_issue_raw: ssl_capable_write (31) says 31

[2020/08/24 17:22:51:6687]  Firmware - pckt len=5 - 00 02 01 28 54
+send
-send
lws_issue_raw: ssl_capable_write (31) says 31

[2020/08/24 17:23:03:1832]  Firmware - pckt len=5 - 00 02 01 28 54
+send
-send
lws_issue_raw: ssl_capable_write (31) says 31

[2020/08/24 17:23:14:6951]  Firmware - pckt len=5 - 00 02 01 28 54
+send
-send
lws_issue_raw: ssl_capable_write (31) says 31

[2020/08/24 17:23:25:9496]  Firmware - pckt len=5 - 00 02 01 28 54
+send
-send
lws_issue_raw: ssl_capable_write (31) says 31
[2020/08/24 17:23:37:4615]  Firmware - pckt len=5 - 00 02 01 28 54
+send
-send
lws_issue_raw: ssl_capable_write (31) says 31
[2020/08/24 17:23:48:8770]  Firmware - pckt len=5 - 00 02 01 28 54
+send
-send
lws_issue_raw: ssl_capable_write (31) says 31
[2020/08/24 17:24:00:3890]  Firmware - pckt len=5 - 00 02 01 28 54
+send
-send
lws_issue_raw: ssl_capable_write (31) says 31
[2020/08/24 17:24:11:9011]  Firmware - pckt len=5 - 00 02 01 28 54
+send
-send
lws_issue_raw: ssl_capable_write (31) says 31

[2020/08/24 17:24:23:4143]  Firmware - pckt len=5 - 00 02 01 28 54
+send
-send
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
lws_issue_raw: ssl_capable_write (31) says 31

What does it mean the last sequence of 4 rows?
I updated the lib with the very last release but nothing changed.

I'm rather sure that it is my fault but I need a clue to solve - but I don't understand why I don't have a similar problem on Tinkerboard ..


Thanks a lot, regards

Stefano


More information about the Libwebsockets mailing list