When connecting to a http stream, if the server crashes or close without properly ending the connection, vlc will enter into an infinite loop, using about 20-25% of the cpu. This infinite loop stops when you press the stop button on the vlc interface.
This loop only happens on windows.
Have you tested this on windows? This issue isn't happening on ubuntu.
I also just uploaded a video demonstrating this issue on https://streams.videolan.org/upload/ .
I can reproduce the problem, this is the location that's looping:
(gdb) bt[#0](https://code.videolan.org/videolan/vlc/-/issues/0) recvmsg (fd=<optimized out>, msg=msg@entry=0x8e4f340, flags=flags@entry=0) at ../../extras/package/win32/../../../compat/recvmsg.c:68[#1](https://code.videolan.org/videolan/vlc/-/issues/1) 0x000007feddbd8f86 in vlc_tls_SocketRead (tls=<optimized out>, iov=<optimized out>, count=<optimized out>) at ../../extras/package/win32/../../../src/network/stream.c:189[#2](https://code.videolan.org/videolan/vlc/-/issues/2) 0x000007feddbd91f4 in vlc_tls_Read (session=session@entry=0x54eaae0, buf=buf@entry=0x5300580, len=len@entry=4, waitall=waitall@entry=true) at ../../extras/package/win32/../../../src/network/stream.c:72[#3](https://code.videolan.org/videolan/vlc/-/issues/3) 0x000007fedd87998a in vlc_https_headers_recv (lenp=<optimized out>, tls=<optimized out>) at ../../extras/package/win32/../../../modules/access/http/h1conn.c:81[#4](https://code.videolan.org/videolan/vlc/-/issues/4) vlc_h1_stream_wait (stream=0x54eab30) at ../../extras/package/win32/../../../modules/access/http/h1conn.c:183[#5](https://code.videolan.org/videolan/vlc/-/issues/5) 0x000007fedd872dcd in vlc_http_stream_read_headers (s=0x54eab30) at ../../extras/package/win32/../../../modules/access/http/message.h:360[#6](https://code.videolan.org/videolan/vlc/-/issues/6) vlc_http_msg_get_initial (s=s@entry=0x54eab30) at ../../extras/package/win32/../../../modules/access/http/message.c:275[#7](https://code.videolan.org/videolan/vlc/-/issues/7) 0x000007fedd87a9c2 in vlc_http_request (mgr=0x6f158b0, host=<optimized out>, port=<optimized out>, req=0x5423c20) at ../../extras/package/win32/../../../modules/access/http/connmgr.c:243[#8](https://code.videolan.org/videolan/vlc/-/issues/8) 0x000007fedd8740f0 in vlc_http_res_open (res=res@entry=0x6dd04e0, opaque=opaque@entry=0x6dd0540) at ../../extras/package/win32/../../../modules/access/http/resource.c:93[#9](https://code.videolan.org/videolan/vlc/-/issues/9) 0x000007fedd874262 in vlc_http_res_get_status (res=0x6dd04e0) at ../../extras/package/win32/../../../modules/access/http/resource.c:138[#10](https://code.videolan.org/videolan/vlc/-/issues/10) 0x000007fedd871930 in Open (obj=0x53c8b90) at ../../extras/package/win32/../../../modules/access/http/access.c:203[#11](https://code.videolan.org/videolan/vlc/-/issues/11) 0x000007feddb76f69 in module_load (obj=obj@entry=0x53c8b90, init=init@entry=0x7feddb76f20 <generic_start>, args=args@entry=0x8e4f978 "\220ï<\005", m=<optimized out>, m=<optimized out>) at ../../extras/package/win32/../../../src/modules/modules.c:168[#12](https://code.videolan.org/videolan/vlc/-/issues/12) 0x000007feddb772b1 in vlc_module_load (obj=obj@entry=0x53c8b90, capability=capability@entry=0x7feddcc608a <__func__.59660+42> "access", name=0x543f3a4 "", strict=strict@entry=true, probe=probe@entry=0x7feddb76f20 <generic_start>) at ../../extras/package/win32/../../../src/modules/modules.c:245[#13](https://code.videolan.org/videolan/vlc/-/issues/13) 0x000007feddb777ae in module_need (obj=obj@entry=0x53c8b90, cap=cap@entry=0x7feddcc608a <__func__.59660+42> "access", name=<optimized out>, strict=strict@entry=true) at ../../extras/package/win32/../../../src/modules/modules.c:336[#14](https://code.videolan.org/videolan/vlc/-/issues/14) 0x000007feddb8f613 in access_New (parent=parent@entry=0x6d49fb0, input=input@entry=0x6f26860, out=<optimized out>, preparsing=<optimized out>, mrl=mrl@entry=0x54e9700 "http://localhost:1337/") at ../../extras/package/win32/../../../src/input/access.c:150[#15](https://code.videolan.org/videolan/vlc/-/issues/15) 0x000007feddb8f8d0 in access_New (mrl=0x54e9700 "http://localhost:1337/", preparsing=<optimized out>, out=<optimized out>, input=0x6f26860, parent=0x6d49fb0) at ../../extras/package/win32/../../../src/input/access.c:113[#16](https://code.videolan.org/videolan/vlc/-/issues/16) stream_AccessNew (parent=parent@entry=0x6d49fb0, input=input@entry=0x6f26860, out=<optimized out>, preparsing=<optimized out>, url=<optimized out>, url@entry=0x54e9700 "http://localhost:1337/") at ../../extras/package/win32/../../../src/input/access.c:295[#17](https://code.videolan.org/videolan/vlc/-/issues/17) 0x000007feddba471d in InputDemuxNew (psz_anchor=0x7feddccaad3 <es_out_timeshift_cbs+595> "", psz_demux=0x543f320 "any", url=0x54e9700 "http://localhost:1337/", p_source=0x6d49fb0, p_input=0x6f26860) at ../../extras/package/win32/../../../src/input/input.c:2456[#18](https://code.videolan.org/videolan/vlc/-/issues/18) InputSourceNew (p_input=p_input@entry=0x6f26860, psz_mrl=<optimized out>, psz_forced_demux=psz_forced_demux@entry=0x0, b_in_can_fail=b_in_can_fail@entry=false) at ../../extras/package/win32/../../../src/input/input.c:2598[#19](https://code.videolan.org/videolan/vlc/-/issues/19) 0x000007feddba78e0 in Init (p_input=p_input@entry=0x6f26860) at ../../extras/package/win32/../../../src/input/input.c:1343[#20](https://code.videolan.org/videolan/vlc/-/issues/20) 0x000007feddbaaf4e in Run (data=0x6f26860) at ../../extras/package/win32/../../../src/input/input.c:527[#21](https://code.videolan.org/videolan/vlc/-/issues/21) 0x000007feddbf78e6 in vlc_entry (p=0x5437b50) at ../../extras/package/win32/../../../src/win32/thread.c:459[#22](https://code.videolan.org/videolan/vlc/-/issues/22) 0x000007fefeda415f in srand () from C:\Windows\system32\msvcrt.dll[#23](https://code.videolan.org/videolan/vlc/-/issues/23) 0x000007fefeda6ebd in msvcrt!_ftime64_s () from C:\Windows\system32\msvcrt.dll[#24](https://code.videolan.org/videolan/vlc/-/issues/24) 0x00000000778a59ed in KERNEL32!BaseThreadInitThunk () from C:\Windows\system32\kernel32.dll[#25](https://code.videolan.org/videolan/vlc/-/issues/25) 0x0000000077adc541 in ntdll!RtlUserThreadStart () from C:\Windows\SYSTEM32\ntdll.dll[#26](https://code.videolan.org/videolan/vlc/-/issues/26) 0x0000000000000000 in ?? ()Backtrace stopped: previous frame inner to this frame (corrupt stack?)(gdb) l63 ret = WSARecvFrom(fd, buf, msg->msg_iovlen, &rcvd, &dwFlags,64 msg->msg_name, &fromlen, NULL, NULL);65 else66 ret = WSARecv(fd, buf, msg->msg_iovlen, &rcvd, &dwFlags,67 NULL, NULL);68 free(buf);6970 if (ret == 0)71 {72 msg->msg_namelen = fromlen;(gdb) p ret$7 = -1(gdb) p (int)WSAGetLastError()gdb: data execution prevention violation at 0x8e4f1ef$8 = 10054(gdb) p *(int*)_errno()gdb: data execution prevention violation at 0x8e4f1ef$9 = 11(gdb) l73 msg->msg_flags = dwFlags;74 return rcvd;75 }7677 switch (WSAGetLastError())78 {79 case WSAEWOULDBLOCK:80 errno = EAGAIN;81 break;82 }
WSARecv() fails, WSAGetLastError() is 10054 (WSAECONNRESET), and because this error is not handled in the switch(), errno stays at 11 (EAGAIN).
Back in vlc_tls_Read(), EAGAIN means it will try again, until someone intervenes.
I think the switch() should handle some other cases as well, or have some default value for errno which isn't EAGAIN.