Opened 2 years ago
#9656 new defect
Linking with libavcodec causes process to hang when returning quickly from main()
Reported by: | Gramner | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | avcodec |
Version: | 4.4.3 | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
The following minimal example consistently hangs on MSYS2 (Windows), although I haven't tested it on other systems:
#include <libavcodec/avcodec.h> int main(void) { avcodec_version(); return 0; }
gcc -O2 -o hang hang.c -lavcodec && ./hang
#0 0x00007ffc7a26cdf4 in ntdll!ZwWaitForSingleObject () from C:\WINDOWS\SYSTEM32\ntdll.dll #1 0x00007ffc77ca1a5e in WaitForSingleObjectEx () from C:\WINDOWS\System32\KernelBase.dll #2 0x00007ffc5c402eff in ?? () from C:\msys64\mingw64\bin\libwinpthread-1.dll #3 0x00007ffc5c40571f in ?? () from C:\msys64\mingw64\bin\libwinpthread-1.dll #4 0x00007ffc4d83452a in ?? () from C:\msys64\mingw64\bin\libgomp-1.dll #5 0x00007ffc4d83a775 in ?? () from C:\msys64\mingw64\bin\libgomp-1.dll #6 0x00007ffc4d81117c in ?? () from C:\msys64\mingw64\bin\libgomp-1.dll #7 0x00007ffc4d81125d in ?? () from C:\msys64\mingw64\bin\libgomp-1.dll #8 0x00007ffc7a1e9a1d in ntdll!RtlActivateActivationContextUnsafeFast () from C:\WINDOWS\SYSTEM32\ntdll.dll #9 0x00007ffc7a22db91 in ntdll!LdrShutdownProcess () from C:\WINDOWS\SYSTEM32\ntdll.dll #10 0x00007ffc7a22da2d in ntdll!RtlExitUserProcess () from C:\WINDOWS\SYSTEM32\ntdll.dll #11 0x00007ffc783ee0ab in KERNEL32!FatalExit () from C:\WINDOWS\System32\kernel32.dll #12 0x00007ffc78faa155 in msvcrt!_exit () from C:\WINDOWS\System32\msvcrt.dll #13 0x00007ffc78faa7c5 in msvcrt!_initterm_e () from C:\WINDOWS\System32\msvcrt.dll #14 0x00007ff7308214a5 in __tmainCRTStartup () at C:/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:324 #15 0x00007ff7308214e6 in mainCRTStartup () at C:/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:202
If the return from main() is delayed just a bit (for example by calling printf() first), the problem goes away, so it's likely some kind of race condition.
This is using the MSYS2-provided libavcodec so it might be caused by some third-party library libavcodec is linking with, but if so I don't know which one:
ffmpeg version 4.4.1 Copyright (c) 2000-2021 the FFmpeg developers built with gcc 11.2.0 (Rev8, Built by MSYS2 project) configuration: --prefix=/mingw64 --target-os=mingw32 --arch=x86_64 --cc=gcc --cxx=g++ --disable-debug --enable-amf --enable-dxva2 --enable-d3d11va --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-iconv --enable-libaom --enable-libass --enable-libbluray --enable-libcaca --enable-libcelt --enable-libdav1d --enable-libfreetype --enable-libgme --enable-libgsm --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libx265 --enable-libxvid --enable-libvpx --enable-libwebp --enable-libxml2 --enable-libzimg --enable-nvenc --enable-openal --enable-pic --enable-postproc --enable-runtime-cpudetect --enable-swresample --enable-version3 --enable-vulkan --enable-zlib --disable-doc --enable-frei0r --enable-libsvtav1 --enable-librav1e --enable-librsvg --logfile=config.log --enable-shared libavutil 56. 70.100 / 56. 70.100 libavcodec 58.134.100 / 58.134.100 libavformat 58. 76.100 / 58. 76.100 libavdevice 58. 13.100 / 58. 13.100 libavfilter 7.110.100 / 7.110.100 libswscale 5. 9.100 / 5. 9.100 libswresample 3. 9.100 / 3. 9.100 libpostproc 55. 9.100 / 55. 9.100
Note:
See TracTickets
for help on using tickets.