[Libwebsockets] valgrind under lwsws

Mario Theodoridis mario.theodoridis at regify.com
Wed Aug 23 09:42:47 CEST 2017


i'm building a websocket server using the v2.2-stable plugin lwsws libuv 
I noticed that running the server in a debugger didn't work for me, even 
when i disabled daemonizing by:

--- a/lwsws/main.c
+++ b/lwsws/main.c
@@ -237,7 +237,7 @@ int main(int argc, char **argv)

         fprintf(stderr, "Root process is %u\n", getpid());

-       while (1) {
+       while (0) {
                 if (do_reload) {
                         do_reload = 0;
                         n = fork();

I worked around the debugging issue by using logging instead and i'm 
fine with that.

Now i'm trying to run the server under valgrind to remove mem leaks. 
Unfortunately i get log entries like:

  268 (12 direct, 256 indirect) bytes in 1 blocks are definitely lost in 
loss record 7 of 8
     at 0x402A17C: malloc (in 
     by 0x495BBE2: ???
     by 0x4972281: ???
     by 0x4976320: ???
     by 0x4044868: ???
     by 0x4044BA6: ???
     by 0x4044D58: ???
     by 0x407C6FB: user_callback_handle_rxflow (libwebsockets.c:1223)
     by 0x40860FB: lws_rx_sm (parsers.c:1484)
     by 0x409928C: lws_interpret_incoming_packet (server.c:2554)
     by 0x407A599: lws_read (handshake.c:239)
     by 0x4080865: lws_service_fd_tsi (service.c:1205)
     by 0x4080A90: lws_service_fd (service.c:1328)
     by 0x409D094: lws_io_cb (libuv.c:101)
     by 0x40C6BBE: uv__poll_io (poll.c:51)
     by 0x40D1FB3: uv__io_poll (linux-core.c:400)
     by 0x40BDB3D: uv_run (core.c:362)
     by 0x409DBAD: lws_libuv_run (libuv.c:414)
     by 0x8049496: main (main.c:299)

And i'm fairly sure that the ??? entries are my plugin.
Both server and plugin are built with the CFLAGS -ggdb3 -O0

What is the best way to get the debug symbols to show up in the valgrind 


Mit Freundlichen Grüßen / Regards

Mario Theodoridis

regify GmbH
Römerstrasse 39 | D-78183 Hüfingen
Amtsgericht Freiburg HRB 709343
Telefon: +49 771 8978 4238

More information about the Libwebsockets mailing list