[Libwebsockets] Infinite loop at lws_service

Andy Green andy at warmcat.com
Wed Aug 22 08:21:31 CEST 2018



On 08/21/2018 11:23 PM, Alfred Sawaya wrote:
> To be more precise, it is in the function rops_periodic_checks_ws.
> 
> If I disable ping pong (ws_ping_pong_interval = 0), it works, as the 
> aforementioned code is never reached.
> 
> Le mar. 21 août 2018 à 17:01, Alfred Sawaya <alfred at huji.fr 
> <mailto:alfred at huji.fr>> a écrit :
> 
>     I use the last libwebsockets version (git+master)
> 
>     Le mar. 21 août 2018 à 17:01, Alfred Sawaya <alfred at huji.fr
>     <mailto:alfred at huji.fr>> a écrit :
> 
>         Hello,
> 
>         I have an issue with libwebsockets. I have done a huge
>         refactored of a piece of software which uses libwebsockets, I
>         used to work but now, I have a strange behaviour, 100% cpu and
>         an infinite loop on the while loop at lib/roles/ws/ops-ws.c : 1407 :
> 
>         (gdb) n
>         1407if (lwsi_role_ws(wsi) &&
>         (gdb)
>         1423wsi = wsi->same_vh_protocol_next;
>         (gdb)
>         1407if (lwsi_role_ws(wsi) &&
>         (gdb)
>         1423wsi = wsi->same_vh_protocol_next;
>         (gdb)
>         1407if (lwsi_role_ws(wsi) &&
>         (gdb)
>         1423wsi = wsi->same_vh_protocol_next;
>         (gdb)
>         1407if (lwsi_role_ws(wsi) &&
>         (gdb)
>         1423wsi = wsi->same_vh_protocol_next;
>         (gdb)
>         1407if (lwsi_role_ws(wsi) &&
>         (gdb)
>         1423wsi = wsi->same_vh_protocol_next;
> 
>         if I do : set  wsi->same_vh_protocol_next = NULL;
>         Then it works as attended.
> 
>         In the code that set wsi->same_vh_protocol_next
>         (lib/roles/ws/client-ws.c : 382), the wsi->same_vh_protocol_next
>         is set to wsi, but I think it should be NULL otherwise
>         while(wsi) loop cannot break, isn't it ?
> 
>         Or I have missed something?

Yeah... that sets the HEAD of the linked-list in the vhost

	wsi->vhost->same_vh_protocol_list[n] = wsi;

it doesn't set the wsi same_vh_protocol_next to itself.

It's cheapest to insert new list members at the head like it does there.


Can you reproduce this problem using the minimal examples, with 
ping-pong enabled or whatever?

-Andy

>         Thank you,
>         Alfred
>         -- 
>         Cordialement,
>         Alfred Sawaya
> 
>     -- 
>     Cordialement,
>     Alfred Sawaya
> 
> -- 
> Cordialement,
> Alfred Sawaya
> 
> 
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> https://libwebsockets.org/mailman/listinfo/libwebsockets
> 



More information about the Libwebsockets mailing list