[Libwebsockets] Suspected memory leak issue while connecting to an unconnectable server

Rick Li rick9370 at gmail.com
Fri Feb 26 03:10:31 CET 2021


Hi,

I had a suspected memory leak issue while connecting to an unconnectable
WebSocket server on v3.2-statble. The scenario is when connected to an
unconnectable WebSocket server(always return HTTP/1.1 301 Moved
Permanently) it will receive "Error: closed before established" on console
output, then I will use those two APIs to cancel and destroy the context of
wsi.
lws_cancel_service(m_pCtx);
lws_context_destroy(m_pCtx);

In my test scenario it will loop for 10000 times then the memory usage will
increase about 2M bytes, I tried to use  UMDH to dump the leak statement
and the log as below.

+ 2826500 ( 2826500 -      0)   5653 allocs BackTrace3DD8748
+    5653 (   5653 -      0) BackTrace3DD8748 allocations

ntdll!RtlWalkHeap+194
ntdll!RtlCaptureStackContext+EC8F
ntdll!RtlAllocateHeap+3E
ucrtbased!calloc_base+D75
ucrtbased!calloc_base+B96
ucrtbased!malloc_dbg+1A
ucrtbased!calloc_base+1295
ucrtbased!realloc_dbg+6B
ucrtbased!realloc+18
websockets!_realloc+50
(G:\websocket\Websocket\Websocket\libwebsockets\lib\core\alloc.c, 109)
websockets!lws_zalloc+30
(G:\websocket\Websocket\Websocket\libwebsockets\lib\core\alloc.c, 135)
websockets!lws_create_event_pipes+68
(G:\websocket\Websocket\Websocket\libwebsockets\lib\core-net\vhost.c, 845)
websockets!lws_create_context+9A3
(G:\websocket\Websocket\Websocket\libwebsockets\lib\core\context.c, 474)
WebsocketClient!wsc::WSClientImp::Setup+49C
(G:\websocket\Websocket\Websocket\WebsocketClient\src\wscImp.cpp, 247)
WebsocketClient!wsc::WSClient::Setup+3F
(G:\websocket\Websocket\Websocket\WebsocketClient\src\wsc.cpp, 18)
WebsocketClientTester!CTest::CTest+19D
(G:\websocket\Websocket\Websocket\WebsocketClientTester\src\WebsocketClientTester.cpp,
54)
WebsocketClientTester!main+739
(G:\websocket\Websocket\Websocket\WebsocketClientTester\src\WebsocketClientTester.cpp,
241)
WebsocketClientTester!invoke_main+33
(d:\agent\_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl,
78)
WebsocketClientTester!__scrt_common_main_seh+157
(d:\agent\_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl,
288)
WebsocketClientTester!__scrt_common_main+D
(d:\agent\_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl,
331)
WebsocketClientTester!mainCRTStartup+8
(d:\agent\_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp, 17)
KERNEL32!BaseThreadInitThunk+19
ntdll!RtlGetAppContainerNamedObjectPath+E4
ntdll!RtlGetAppContainerNamedObjectPath+B4

It shows lws_create_event_pipes has not been free sometimes, can you give
me some suggestions? Thanks for your help.

Best Regards,
Rick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20210226/c295ce33/attachment.htm>


More information about the Libwebsockets mailing list