Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression on May 14th build #217

Closed
CrendKing opened this issue May 25, 2022 · 19 comments
Closed

Regression on May 14th build #217

CrendKing opened this issue May 25, 2022 · 19 comments

Comments

@CrendKing
Copy link

CrendKing commented May 25, 2022

There seems to be a regression on May 14th build (and all builds afterwards) about fontconfig.

Steps to reproduce

  1. Download and extract https://github.com/shinchiro/mpv-winbuild-cmake/releases/download/20220514/mpv-x86_64-20220514-git-d27c85b.7z
  2. Create the "portable_config" directory, and inside a "fonts.conf", which has the following content:
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
    <dir>C:\Windows\Fonts</dir>
    <cachedir>C:\Windows\Temp</cachedir>
</fontconfig>
  1. Run mpv.exe --osd-font-provider=fontconfig --log-file=C:\mpv.log

Expected result

The mpv pseduo gui window should show up.

Actual result

Nothing happens. The log file ends with [ 0.006][v][osd/libass] Setting up fonts...

Apparently, mpv.exe crashed. %LOCALAPPDATA%\CrashDumps contains the crash dump.

Workaround

A workaround I found is that the crash seems to be caused by lack of fontconfig dir cache. If I run the command with May 13th build, populate the dir cache first, then run May 14th build, it works from then on. So far I need to keep a copy of the 13th build so that any time I install/remove a font, I run with that build once first.

Other info

May 13th build and earlier are OK. It seems the switch to meson build is not 100% equivalent.

I also built mpv myself. With both the same hash that May 14th is based on and the latest commit, it works fine. So pretty sure the upstream is not the culprit.

Is there a debug build with symbols so I could provide you crash info, in case you can't reproduce yourself?

@zhongfly
Copy link
Contributor

zhongfly commented May 25, 2022

@CrendKing
Copy link
Author

Thanks. The package mpv-x86_64-20220514-git-d27c85b.7z has the same issue. I don't know how to make use of mpv-debug-x86_64-20220514-git-d27c85b.7z. The extracted "mpv.debug" doesn't seem to be valid exe (e.g. its import table is messed up).

@zhongfly
Copy link
Contributor

Thanks. The package mpv-x86_64-20220514-git-d27c85b.7z has the same issue. I don't know how to make use of mpv-debug-x86_64-20220514-git-d27c85b.7z. The extracted "mpv.debug" doesn't seem to be valid exe (e.g. its import table is messed up).

Put mpv.debug and mpv.exe in the same folder, the log I get using gdb is as follows:

GNU gdb (GDB) 10.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from mpv...
Reading symbols from D:\Users\Downloads\Compressed\mpv-x86_64-20220524-git-9022b1b\mpv.debug...
(gdb) run
Starting program: D:\Users\Downloads\Compressed\mpv-x86_64-20220524-git-9022b1b\mpv.exe "--osd-font-provider=fontconfig" "--log-file=mpv.log"
[New Thread 18268.0x5644]
[New Thread 18268.0x1eec]
[New Thread 18268.0x2964]
warning: Can not parse XML library list; XML support was disabled at compile time
[New Thread 18268.0x5a50]
[New Thread 18268.0x42e8]
[New Thread 18268.0x40e0]
[New Thread 18268.0x2980]
[New Thread 18268.0x3134]
[New Thread 18268.0x186c]
[Thread 18268.0x186c exited with code 0]

Thread 9 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 18268.0x3134]

@CrendKing
Copy link
Author

CrendKing commented May 25, 2022

Thanks. Here is the call stack when seg fault:

(gdb) where
#0  0x00007ff789c873c0 in opendir ()
#1  0x00007ff78938af8c in FcDirScanConfig (set=set@entry=0x1b645393010, dirs=dirs@entry=0x1b645393050,
    dir=dir@entry=0x1b645393a80 "C:/Windows/Fonts", force=force@entry=1, config=config@entry=0x1b645811a30)
    at /__w/mpv-winbuild/mpv-winbuild/mpv-winbuild-cmake/src_packages/fontconfig/src/fcdir.c:229
#2  0x00007ff78938b3fd in FcDirCacheScan (dir=dir@entry=0x1b645393a80 "C:/Windows/Fonts", config=config@entry=0x1b645811a30)
    at /__w/mpv-winbuild/mpv-winbuild/mpv-winbuild-cmake/src_packages/fontconfig/src/fcdir.c:366
#3  0x00007ff78938b62b in FcDirCacheRead (dir=dir@entry=0x1b645393a80 "C:/Windows/Fonts", force=force@entry=0, config=config@entry=0x1b645811a30)
    at /__w/mpv-winbuild/mpv-winbuild/mpv-winbuild-cmake/src_packages/fontconfig/src/fcdir.c:474
#4  0x00007ff78938605e in FcConfigAddDirList (config=config@entry=0x1b645811a30, set=set@entry=FcSetSystem, dirSet=0x1b645811bb0)
    at /__w/mpv-winbuild/mpv-winbuild/mpv-winbuild-cmake/src_packages/fontconfig/src/fccfg.c:513
#5  0x00007ff789386122 in FcConfigBuildFonts (config=0x1b645811a30)
    at /__w/mpv-winbuild/mpv-winbuild/mpv-winbuild-cmake/src_packages/fontconfig/src/fccfg.c:547
#6  0x00007ff789380363 in ass_fontconfig_add_provider (lib=0x1b64539af20, selector=0x1b6453984a0,
    config=0x1b6453988e0 "C:/mpv/portable_config/fonts.conf", ftlib=<optimized out>)
    at /__w/mpv-winbuild/mpv-winbuild/mpv-winbuild-cmake/src_packages/libass/libass/ass_fontconfig.c:341
#7  0x00007ff78937e5f9 in ass_fontselect_init (library=0x1b64539af20, ftlibrary=0x1b6435eff50, num_emfonts=num_emfonts@entry=0x1b645398008,
    family=family@entry=0x1b644feb8e0 "sans-serif", path=path@entry=0x0, config=config@entry=0x1b6453988e0 "C:/mpv/portable_config/fonts.conf",
    dfp=dfp@entry=ASS_FONTPROVIDER_FONTCONFIG) at /__w/mpv-winbuild/mpv-winbuild/mpv-winbuild-cmake/src_packages/libass/libass/ass_fontselect.c:1105
#8  0x00007ff78936321e in ass_set_fonts (priv=0x1b645397ff0, default_font=0x0, default_family=0x1b644feb8e0 "sans-serif", dfp=3,
    config=0x1b6453988e0 "C:/mpv/portable_config/fonts.conf", update=1)
    at /__w/mpv-winbuild/mpv-winbuild/mpv-winbuild-cmake/src_packages/libass/libass/ass_render_api.c:157
#9  0x00007ff786830e75 in mp_ass_configure_fonts ()
#10 0x00007ff78683ba77 in create_ass_track ()
#11 0x00007ff78683be2b in osd_set_external ()
#12 0x00007ff786802c2b in cmd_osd_overlay ()
#13 0x00007ff78681237e in run_command ()
#14 0x00007ff7867ff3cd in mpv_command_node ()
#15 0x00007ff786899472 in script_command_native ()
#16 0x00007ff789636c58 in lj_BC_JFUNCV ()
#17 0x00007ff789629074 in lua_pcall (L=0x1b645570380, nargs=<optimized out>, nresults=-1, errfunc=<optimized out>)
    at /__w/mpv-winbuild/mpv-winbuild/mpv-winbuild-cmake/src_packages/luajit/src/lj_api.c:1116
#18 0x00007ff786897962 in script_autofree_trampoline ()
#19 0x00007ff789636c58 in lj_BC_JFUNCV ()
#20 0x00007ff78689a013 in load_scripts ()
#21 0x00007ff789636c58 in lj_BC_JFUNCV ()
#22 0x00007ff789629074 in lua_pcall (L=0x1b645570380, nargs=<optimized out>, nresults=0, errfunc=<optimized out>)
    at /__w/mpv-winbuild/mpv-winbuild/mpv-winbuild-cmake/src_packages/luajit/src/lj_api.c:1116
#23 0x00007ff78689825c in run_lua ()
#24 0x00007ff789636c58 in lj_BC_JFUNCV ()
#25 0x00007ff7896291dd in lua_cpcall (L=<optimized out>, func=<optimized out>, ud=<optimized out>)
    at /__w/mpv-winbuild/mpv-winbuild/mpv-winbuild-cmake/src_packages/luajit/src/lj_api.c:1173
#26 0x00007ff78689687c in load_lua ()
#27 0x00007ff786825eae in run_script ()
#28 0x00007ff7868263ce in script_thread ()

So we know it is related to fontconfig. Not sure why opendir() would crash. But I guess if the cache already exists, the whole FcDirScanConfig call is skipped, which avoids crash.

I wonder is the fontconfig version changed between May 13 and 14 build?

@shinchiro
Copy link
Owner

shinchiro commented May 30, 2022

I tried to revert a724e4b and build mpv with waf and this problem disappeared. Not sure why this happen but the crash only happen when building with meson. Maybe you can open this issue on mpv and link it to this issue?

Edit:
Wait, I know why it happen

@zhongfly
Copy link
Contributor

zhongfly commented May 30, 2022

I found the problem still happens
https://github.com/zhongfly/mpv-winbuild/actions/runs/2408265793

D:\Users\Downloads\Compressed\mpv-x86_64-20220530-git-afe2902>gdb --args mpv --osd-font-provider=fontconfig
GNU gdb (GDB) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from mpv...
Reading symbols from D:\Users\Downloads\Compressed\mpv-x86_64-20220530-git-afe2902\mpv.debug...
(gdb) run
Starting program: D:\Users\Downloads\Compressed\mpv-x86_64-20220530-git-afe2902\mpv.exe "--osd-font-provider=fontconfig"
[New Thread 25032.0x4348]
[New Thread 25032.0x6078]
[New Thread 25032.0x3a24]
[New Thread 25032.0x2a58]
[New Thread 25032.0x3080]
[New Thread 25032.0x49c0]
[New Thread 25032.0x2d80]
[New Thread 25032.0x23dc]
[Thread 25032.0x23dc exited with code 0]

Thread 8 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 25032.0x2d80]
0x00007ff6b2ced1bc in opendir ()
(gdb) where
#0  0x00007ff6b2ced1bc in opendir ()
#1  0x00007ff6b23d810c in FcDirScanConfig (set=set@entry=0x17510e71920, dirs=dirs@entry=0x17510e71960,
    dir=dir@entry=0x17510ab2ff0 "C:/Windows/Fonts", force=force@entry=1, config=config@entry=0x17510e71380)
    at /__w/mpv-winbuild/mpv-winbuild/mpv-winbuild-cmake/src_packages/fontconfig/src/fcdir.c:229
#2  0x00007ff6b23d8575 in FcDirCacheScan (dir=dir@entry=0x17510ab2ff0 "C:/Windows/Fonts",
    config=config@entry=0x17510e71380)
    at /__w/mpv-winbuild/mpv-winbuild/mpv-winbuild-cmake/src_packages/fontconfig/src/fcdir.c:366
#3  0x00007ff6b23d87b3 in FcDirCacheRead (dir=dir@entry=0x17510ab2ff0 "C:/Windows/Fonts", force=force@entry=0,
    config=config@entry=0x17510e71380)
    at /__w/mpv-winbuild/mpv-winbuild/mpv-winbuild-cmake/src_packages/fontconfig/src/fcdir.c:474
#4  0x00007ff6b23d33ef in FcConfigAddDirList (config=config@entry=0x17510e71380, set=set@entry=FcSetSystem,
    dirSet=0x17510e71550) at /__w/mpv-winbuild/mpv-winbuild/mpv-winbuild-cmake/src_packages/fontconfig/src/fccfg.c:513
#5  0x00007ff6b23d34ab in FcConfigBuildFonts (config=0x17510e71380)
    at /__w/mpv-winbuild/mpv-winbuild/mpv-winbuild-cmake/src_packages/fontconfig/src/fccfg.c:547
#6  0x00007ff6b23c6316 in ass_fontconfig_add_provider (lib=0x17510ab9750, selector=0x17510e710f0,
    config=0x17510e711d0 "D:/Users/Downloads/Compressed/mpv-x86_64-20220530-git-afe2902/portable_config/fonts.conf",
    ftlib=<optimized out>)
    at /__w/mpv-winbuild/mpv-winbuild/mpv-winbuild-cmake/src_packages/libass/libass/ass_fontconfig.c:341
#7  0x00007ff6b23ba485 in ass_fontselect_init (library=0x17510ab9750, ftlibrary=0x1750ece84e0,
    num_emfonts=num_emfonts@entry=0x17510ab24b8, family=family@entry=0x17510709ae0 "sans-serif", path=path@entry=0x0,
    config=config@entry=0x17510e711d0 "D:/Users/Downloads/Compressed/mpv-x86_64-20220530-git-afe2902/portable_config/fonts.conf", dfp=dfp@entry=ASS_FONTPROVIDER_FONTCONFIG)
    at /__w/mpv-winbuild/mpv-winbuild/mpv-winbuild-cmake/src_packages/libass/libass/ass_fontselect.c:1105
#8  0x00007ff6b23a73ae in ass_set_fonts (priv=priv@entry=0x17510ab24a0, default_font=default_font@entry=0x0,
    default_family=0x17510709ae0 "sans-serif", dfp=dfp@entry=3,
    config=config@entry=0x17510e711d0 "D:/Users/Downloads/Compressed/mpv-x86_64-20220530-git-afe2902/portable_config/fonts.conf", update=update@entry=1)
    at /__w/mpv-winbuild/mpv-winbuild/mpv-winbuild-cmake/src_packages/libass/libass/ass_render_api.c:157
#9  0x00007ff6af8626e8 in mp_ass_configure_fonts (priv=0x17510ab24a0, opts=0x17510709a10, global=<optimized out>,
    log=0x17510ab96f0) at ../../../../../src_packages/mpv/sub/ass_mp.c:107
#10 0x00007ff6af869447 in create_ass_renderer (ass=0x17510ab9468, osd=0x175107095f0)
    at ../../../../../src_packages/mpv/sub/osd_libass.c:64
#11 create_ass_track (osd=osd@entry=0x175107095f0, obj=obj@entry=0x1751070a4e0, ass=ass@entry=0x17510ab9468)
    at ../../../../../src_packages/mpv/sub/osd_libass.c:125
#12 0x00007ff6af869aa9 in update_external (ext=<optimized out>, obj=0x1751070a4e0, osd=0x175107095f0)
    at ../../../../../src_packages/mpv/sub/osd_libass.c:506
#13 osd_set_external (osd=0x175107095f0, ov=ov@entry=0x4817dff5d0)
    at ../../../../../src_packages/mpv/sub/osd_libass.c:584
#14 0x00007ff6af83d211 in cmd_osd_overlay (p=0x17510ab9180) at ../../../../../src_packages/mpv/player/command.c:4405
#15 0x00007ff6af849a5a in run_command (mpctx=0x17510644630, cmd=0x17510ab8d30, abort=<optimized out>,
    on_completion=<optimized out>, on_completion_priv=0x4817dff6e0)
    at ../../../../../src_packages/mpv/player/command.c:4751
#16 0x00007ff6af838d85 in run_client_command (ctx=ctx@entry=0x17510aa87f0, cmd=0x17510ab8d30,
    res=res@entry=0x4817dff790) at ../../../../../src_packages/mpv/player/client.c:1137
#17 0x00007ff6af83ae37 in mpv_command_node (ctx=0x17510aa87f0, args=args@entry=0x4817dff7e0,
    result=result@entry=0x4817dff7f0) at ../../../../../src_packages/mpv/player/client.c:1155
#18 0x00007ff6af8b5a52 in script_command_native (L=0x17510570380, tmp=0x17510ab8240)
    at ../../../../../src_packages/mpv/player/lua.c:968
#19 0x00007ff6b268bae8 in lj_BC_JFUNCV ()
#20 0x00007ff6b267e3a2 in lua_pcall (L=L@entry=0x17510570380, nargs=<optimized out>, nresults=nresults@entry=-1,
    errfunc=errfunc@entry=0)
    at /__w/mpv-winbuild/mpv-winbuild/mpv-winbuild-cmake/src_packages/luajit/src/lj_api.c:1116
#21 0x00007ff6af8b3ea1 in script_autofree_trampoline (L=0x17510570380)
    at ../../../../../src_packages/mpv/player/lua.c:1278
#22 0x00007ff6b268bae8 in lj_BC_JFUNCV ()
#23 0x00007ff6af8b6541 in load_scripts (L=0x17510570380) at ../../../../../src_packages/mpv/player/lua.c:327
#24 0x00007ff6b268bae8 in lj_BC_JFUNCV ()
#25 0x00007ff6b267e3a2 in lua_pcall (L=L@entry=0x17510570380, nargs=nargs@entry=0, nresults=nresults@entry=0,
    errfunc=errfunc@entry=-2)
    at /__w/mpv-winbuild/mpv-winbuild/mpv-winbuild-cmake/src_packages/luajit/src/lj_api.c:1116
#26 0x00007ff6af8b47dd in run_lua (L=0x17510570380) at ../../../../../src_packages/mpv/player/lua.c:429
#27 0x00007ff6b268bae8 in lj_BC_JFUNCV ()
#28 0x00007ff6b267e50d in lua_cpcall (L=L@entry=0x17510570380, func=func@entry=0x7ff6af8b44e0 <run_lua>,
    ud=ud@entry=0x17510ab0770)
    at /__w/mpv-winbuild/mpv-winbuild/mpv-winbuild-cmake/src_packages/luajit/src/lj_api.c:1173
#29 0x00007ff6af8b2e43 in load_lua (args=<optimized out>) at ../../../../../src_packages/mpv/player/lua.c:470
#30 0x00007ff6af859baa in run_script (arg=arg@entry=0x17510aa8740)
    at ../../../../../src_packages/mpv/player/scripting.c:91
#31 0x00007ff6af85a0bd in script_thread (p=p@entry=0x17510aa8740)
    at ../../../../../src_packages/mpv/player/scripting.c:103
#32 0x00007ff6af8a3af0 in run_thread (lpParameter=<optimized out>)
    at ../../../../../src_packages/mpv/osdep/win32/pthread.c:219
#33 0x00007ff91e477034 in KERNEL32!BaseThreadInitThunk () from C:\WINDOWS\System32\kernel32.dll
#34 0x00007ff91fa82651 in ntdll!RtlUserThreadStart () from C:\WINDOWS\SYSTEM32\ntdll.dll
#35 0x0000000000000000 in ?? ()

shinchiro added a commit that referenced this issue May 30, 2022
Fix #217. Also disable asserts
@shinchiro
Copy link
Owner

Should really fix this problem

@zhongfly
Copy link
Contributor

The problem persists, the gui window is still not displayed on version 20220531.

@CrendKing
Copy link
Author

CrendKing commented May 31, 2022

Can confirm. The problem is, when I build mpv with Meson in MinGW, there is no such problem. So I'm pretty sure the issue is specific to this repo's build. Of course, my build does not have the same set of features enabled, so it could still be coming from mpv.

@shinchiro
Copy link
Owner

Are you sure? I just downloaded the 20220531 x64 archive and it shows gui windows with --osd-font-provider=fontconfig

@CrendKing
Copy link
Author

Don't forget you also need fonts.conf. See the first post.

@CrendKing
Copy link
Author

Hi, is this is still being worked on? Can we reopen the issue for better tracking? Thanks.

@CrendKing
Copy link
Author

CrendKing commented Jun 15, 2022

@shinchiro @zhongfly I spent some time to build mpv locally (in WSL) with this repo's scripts. I can reproduce the issue locally. So I did some tests.

Apparently, in MinGW, the dirent.c (which hosts opendir) is also the source of wdirent.c, the Unicode variant. The latter exports functions like _wopendir.

The crash site at opendir apparently is caused by a weird stack pointer issue, according to the assembly in gdb. Before calling opendir(s_dir), I can see s_dir points to the correct string. However, inside opendir, the parameter szPath suddenly becomes 0x1, which is invalid pointer. Therefore, the first access to that pointer results access denied exception (0xC0000005 in Windows).

However, if I replace opendir with _wopendir(L"C:/Windows/Fonts"), it will function properly. Dumbfounded, I compared the disassembly of the first few instructions of them (last line is where opendir crashes):

opendir:

   0x00007ff6469bdb70 <+0>:     push   %r12
   0x00007ff6469bdb72 <+2>:     push   %rbp
   0x00007ff6469bdb73 <+3>:     push   %rdi
   0x00007ff6469bdb74 <+4>:     push   %rsi
   0x00007ff6469bdb75 <+5>:     push   %rbx
   0x00007ff6469bdb76 <+6>:     sub    $0x150,%rsp
   0x00007ff6469bdb7d <+13>:    mov    %rcx,%rbp
   0x00007ff6469bdb80 <+16>:    mov    %rdx,%rsi
   0x00007ff6469bdb83 <+19>:    test   %rdx,%rdx
   0x00007ff6469bdb86 <+22>:    je     0x7ff6469bdcc0 <opendir+336>
   0x00007ff6469bdb8c <+28>:    cmpb   $0x0,(%rdx)

_wopendir:

   0x00007ff65db105c0 <+0>:     push   %r12
   0x00007ff65db105c2 <+2>:     push   %rbp
   0x00007ff65db105c3 <+3>:     push   %rdi
   0x00007ff65db105c4 <+4>:     push   %rsi
   0x00007ff65db105c5 <+5>:     push   %rbx
   0x00007ff65db105c6 <+6>:     sub    $0x230,%rsp
   0x00007ff65db105cd <+13>:    mov    %rcx,%rbx
   0x00007ff65db105d0 <+16>:    call   0x7ff65eac5050 <_errno>
   0x00007ff65db105d5 <+21>:    movl   $0x0,(%rax)
   0x00007ff65db105db <+27>:    test   %rbx,%rbx
   0x00007ff65db105de <+30>:    je     0x7ff65db10720 <_wopendir+352>
   0x00007ff65db105e4 <+36>:    cmpw   $0x0,(%rbx)

The 0x1 comes from %rsi. So it seems to me the problem comes from some kind of conflict between opendir and _wopendir. I went to search the whole code base (mpv and all the dependencies), see which of them uses both these two functions. Guess what, mpv is the only one! _wopendir is used at https://github.com/mpv-player/mpv/blob/602995fd40f03440f5fa64113b6188cb46ffcc9c/osdep/io.c#L565. All other dependencies either only use opendir (99.9% of all) or only _wopendir (luajit).

I think MinGW's dirent or fontconfig individually are fine, but the way this repo links them into mpv somehow messes up something, of which I don't know.

I'll probably try the May 13th version, see why that build works.

BTW, I know you mentioned before, in order to build this in WSL, the instruction from README.md is not enough. For example, pkgconf is needed. autoconf and automake also need to be built from source, since the ones from apt is too old.

@shinchiro
Copy link
Owner

Try revert commit a724e4b & build it. See the problem still occur or not

@CrendKing
Copy link
Author

CrendKing commented Jun 15, 2022

As expected, reverting a724e4b off HEAD fixes the issue. So the meson switch is the culprit. Here is the assembly for opendir:

   0x00007ff63076d8c0 <+0>:     push   %rbp
   0x00007ff63076d8c1 <+1>:     push   %rdi
   0x00007ff63076d8c2 <+2>:     push   %rsi
   0x00007ff63076d8c3 <+3>:     push   %rbx
   0x00007ff63076d8c4 <+4>:     sub    $0x138,%rsp
   0x00007ff63076d8cb <+11>:    mov    %rcx,%rbx
   0x00007ff63076d8ce <+14>:    call   0x7ff633519eb0 <_errno>
   0x00007ff63076d8d3 <+19>:    movl   $0x0,(%rax)
   0x00007ff63076d8d9 <+25>:    test   %rbx,%rbx
   0x00007ff63076d8dc <+28>:    je     0x7ff63076da70 <opendir+432>
   0x00007ff63076d8e2 <+34>:    cmpb   $0x0,(%rbx)
   0x00007ff63076d8e5 <+37>:    je     0x7ff63076da38 <opendir+376>

You can see this is similar to _wopendir above.

Since all dependencies are unaffected by a724e4b, I went to compare the effective linking command from waf and Meson. Turns out, if I just replace the Meson's linking command line with waf's, the resulting exe will work!

waf:

/home/ck/m/b/install/bin/x86_64-w64-mingw32-gcc -Wl,--enable-auto-import -Wl,--dynamicbase -Wl,--nxcompat -Wl,--high-entropy-va -Wl,--nxcompat -Wl,--no-seh -Wl,--dynamicbase -Wl,--dynamicbase -Wl,--nxcompat -Wl,--high-entropy-va osdep_mpv.rc_mpv.o mpv.exe.p/audio_aframe.c.obj mpv.exe.p/audio_chmap.c.obj mpv.exe.p/audio_chmap_sel.c.obj mpv.exe.p/audio_decode_ad_lavc.c.obj mpv.exe.p/audio_decode_ad_spdif.c.obj mpv.exe.p/audio_filter_af_drop.c.obj mpv.exe.p/audio_filter_af_format.c.obj mpv.exe.p/audio_filter_af_lavcac3enc.c.obj mpv.exe.p/audio_filter_af_scaletempo.c.obj mpv.exe.p/audio_filter_af_scaletempo2.c.obj mpv.exe.p/audio_filter_af_scaletempo2_internals.c.obj mpv.exe.p/audio_fmt-conversion.c.obj mpv.exe.p/audio_format.c.obj mpv.exe.p/audio_out_ao.c.obj mpv.exe.p/audio_out_ao_lavc.c.obj mpv.exe.p/audio_out_ao_null.c.obj mpv.exe.p/audio_out_ao_pcm.c.obj mpv.exe.p/audio_out_buffer.c.obj mpv.exe.p/common_av_common.c.obj mpv.exe.p/common_av_log.c.obj mpv.exe.p/common_codecs.c.obj mpv.exe.p/common_common.c.obj mpv.exe.p/common_encode_lavc.c.obj mpv.exe.p/common_msg.c.obj mpv.exe.p/common_playlist.c.obj mpv.exe.p/common_recorder.c.obj mpv.exe.p/common_stats.c.obj mpv.exe.p/common_tags.c.obj mpv.exe.p/common_version.c.obj mpv.exe.p/demux_codec_tags.c.obj mpv.exe.p/demux_cue.c.obj mpv.exe.p/demux_cache.c.obj mpv.exe.p/demux_demux.c.obj mpv.exe.p/demux_demux_cue.c.obj mpv.exe.p/demux_demux_disc.c.obj mpv.exe.p/demux_demux_edl.c.obj mpv.exe.p/demux_demux_lavf.c.obj mpv.exe.p/demux_demux_mf.c.obj mpv.exe.p/demux_demux_mkv.c.obj mpv.exe.p/demux_demux_mkv_timeline.c.obj mpv.exe.p/demux_demux_null.c.obj mpv.exe.p/demux_demux_playlist.c.obj mpv.exe.p/demux_demux_raw.c.obj mpv.exe.p/demux_demux_timeline.c.obj mpv.exe.p/demux_ebml.c.obj mpv.exe.p/demux_packet.c.obj mpv.exe.p/demux_timeline.c.obj mpv.exe.p/filters_f_async_queue.c.obj mpv.exe.p/filters_f_autoconvert.c.obj mpv.exe.p/filters_f_auto_filters.c.obj mpv.exe.p/filters_f_decoder_wrapper.c.obj mpv.exe.p/filters_f_demux_in.c.obj mpv.exe.p/filters_f_hwtransfer.c.obj mpv.exe.p/filters_f_lavfi.c.obj mpv.exe.p/filters_f_output_chain.c.obj mpv.exe.p/filters_f_swresample.c.obj mpv.exe.p/filters_f_swscale.c.obj mpv.exe.p/filters_f_utils.c.obj mpv.exe.p/filters_filter.c.obj mpv.exe.p/filters_frame.c.obj mpv.exe.p/filters_user_filters.c.obj mpv.exe.p/input_cmd.c.obj mpv.exe.p/input_event.c.obj mpv.exe.p/input_input.c.obj mpv.exe.p/input_ipc.c.obj mpv.exe.p/input_keycodes.c.obj mpv.exe.p/misc_bstr.c.obj mpv.exe.p/misc_charset_conv.c.obj mpv.exe.p/misc_dispatch.c.obj mpv.exe.p/misc_json.c.obj mpv.exe.p/misc_natural_sort.c.obj mpv.exe.p/misc_node.c.obj mpv.exe.p/misc_rendezvous.c.obj mpv.exe.p/misc_thread_pool.c.obj mpv.exe.p/misc_thread_tools.c.obj mpv.exe.p/options_m_config_core.c.obj mpv.exe.p/options_m_config_frontend.c.obj mpv.exe.p/options_m_option.c.obj mpv.exe.p/options_m_property.c.obj mpv.exe.p/options_options.c.obj mpv.exe.p/options_parse_commandline.c.obj mpv.exe.p/options_parse_configfile.c.obj mpv.exe.p/options_path.c.obj mpv.exe.p/player_audio.c.obj mpv.exe.p/player_client.c.obj mpv.exe.p/player_command.c.obj mpv.exe.p/player_configfiles.c.obj mpv.exe.p/player_external_files.c.obj mpv.exe.p/player_loadfile.c.obj mpv.exe.p/player_main.c.obj mpv.exe.p/player_misc.c.obj mpv.exe.p/player_osd.c.obj mpv.exe.p/player_playloop.c.obj mpv.exe.p/player_screenshot.c.obj mpv.exe.p/player_scripting.c.obj mpv.exe.p/player_sub.c.obj mpv.exe.p/player_video.c.obj mpv.exe.p/stream_cookies.c.obj mpv.exe.p/stream_stream.c.obj mpv.exe.p/stream_stream_avdevice.c.obj mpv.exe.p/stream_stream_cb.c.obj mpv.exe.p/stream_stream_concat.c.obj mpv.exe.p/stream_stream_edl.c.obj mpv.exe.p/stream_stream_file.c.obj mpv.exe.p/stream_stream_lavf.c.obj mpv.exe.p/stream_stream_memory.c.obj mpv.exe.p/stream_stream_mf.c.obj mpv.exe.p/stream_stream_null.c.obj mpv.exe.p/stream_stream_slice.c.obj mpv.exe.p/sub_ass_mp.c.obj mpv.exe.p/sub_dec_sub.c.obj mpv.exe.p/sub_draw_bmp.c.obj mpv.exe.p/sub_filter_sdh.c.obj mpv.exe.p/sub_img_convert.c.obj mpv.exe.p/sub_lavc_conv.c.obj mpv.exe.p/sub_osd.c.obj mpv.exe.p/sub_osd_libass.c.obj mpv.exe.p/sub_sd_ass.c.obj mpv.exe.p/sub_sd_lavc.c.obj mpv.exe.p/video_csputils.c.obj mpv.exe.p/video_decode_vd_lavc.c.obj mpv.exe.p/video_filter_refqueue.c.obj mpv.exe.p/video_filter_vf_format.c.obj mpv.exe.p/video_filter_vf_sub.c.obj mpv.exe.p/video_fmt-conversion.c.obj mpv.exe.p/video_hwdec.c.obj mpv.exe.p/video_image_loader.c.obj mpv.exe.p/video_image_writer.c.obj mpv.exe.p/video_img_format.c.obj mpv.exe.p/video_mp_image.c.obj mpv.exe.p/video_mp_image_pool.c.obj mpv.exe.p/video_out_aspect.c.obj mpv.exe.p/video_out_bitmap_packer.c.obj mpv.exe.p/video_out_dither.c.obj mpv.exe.p/video_out_dr_helper.c.obj mpv.exe.p/video_out_filter_kernels.c.obj mpv.exe.p/video_out_gpu_context.c.obj mpv.exe.p/video_out_gpu_error_diffusion.c.obj mpv.exe.p/video_out_gpu_hwdec.c.obj mpv.exe.p/video_out_gpu_lcms.c.obj mpv.exe.p/video_out_gpu_libmpv_gpu.c.obj mpv.exe.p/video_out_gpu_osd.c.obj mpv.exe.p/video_out_gpu_ra.c.obj mpv.exe.p/video_out_gpu_shader_cache.c.obj mpv.exe.p/video_out_gpu_spirv.c.obj mpv.exe.p/video_out_gpu_user_shaders.c.obj mpv.exe.p/video_out_gpu_utils.c.obj mpv.exe.p/video_out_gpu_video.c.obj mpv.exe.p/video_out_gpu_video_shaders.c.obj mpv.exe.p/video_out_libmpv_sw.c.obj mpv.exe.p/video_out_vo.c.obj mpv.exe.p/video_out_vo_gpu.c.obj mpv.exe.p/video_out_vo_image.c.obj mpv.exe.p/video_out_vo_lavc.c.obj mpv.exe.p/video_out_vo_libmpv.c.obj mpv.exe.p/video_out_vo_null.c.obj mpv.exe.p/video_out_vo_tct.c.obj mpv.exe.p/video_out_win_state.c.obj mpv.exe.p/video_repack.c.obj mpv.exe.p/video_sws_utils.c.obj mpv.exe.p/osdep_io.c.obj mpv.exe.p/osdep_semaphore_osx.c.obj mpv.exe.p/osdep_subprocess.c.obj mpv.exe.p/osdep_threads.c.obj mpv.exe.p/osdep_timer.c.obj mpv.exe.p/ta_ta.c.obj mpv.exe.p/ta_ta_talloc.c.obj mpv.exe.p/ta_ta_utils.c.obj mpv.exe.p/osdep_win32_pthread.c.obj mpv.exe.p/osdep_timer-win2.c.obj mpv.exe.p/osdep_w32_keyboard.c.obj mpv.exe.p/osdep_windows_utils.c.obj mpv.exe.p/input_ipc-win.c.obj mpv.exe.p/osdep_main-fn-win.c.obj mpv.exe.p/osdep_path-win.c.obj mpv.exe.p/osdep_subprocess-win.c.obj mpv.exe.p/osdep_terminal-win.c.obj mpv.exe.p/video_out_w32_common.c.obj mpv.exe.p/video_out_win32_displayconfig.c.obj mpv.exe.p/video_out_win32_droptarget.c.obj mpv.exe.p/osdep_glob-win.c.obj mpv.exe.p/player_javascript.c.obj mpv.exe.p/sub_filter_jsre.c.obj mpv.exe.p/demux_demux_libarchive.c.obj mpv.exe.p/stream_stream_libarchive.c.obj mpv.exe.p/stream_stream_bluray.c.obj mpv.exe.p/player_lua.c.obj mpv.exe.p/audio_filter_af_rubberband.c.obj mpv.exe.p/input_sdl_gamepad.c.obj mpv.exe.p/video_filter_vf_vapoursynth.c.obj mpv.exe.p/video_filter_vf_fingerprint.c.obj mpv.exe.p/video_zimg.c.obj mpv.exe.p/audio_out_ao_openal.c.obj mpv.exe.p/audio_out_ao_sdl.c.obj mpv.exe.p/audio_out_ao_wasapi.c.obj mpv.exe.p/audio_out_ao_wasapi_changenotify.c.obj mpv.exe.p/audio_out_ao_wasapi_utils.c.obj mpv.exe.p/video_out_vo_direct3d.c.obj mpv.exe.p/video_out_placebo_ra_pl.c.obj mpv.exe.p/video_out_placebo_utils.c.obj mpv.exe.p/video_out_vo_gpu_next.c.obj mpv.exe.p/video_out_gpu_next_context.c.obj mpv.exe.p/video_out_vo_sdl.c.obj mpv.exe.p/video_out_gpu_spirv_shaderc.c.obj mpv.exe.p/video_out_d3d11_context.c.obj mpv.exe.p/video_out_d3d11_ra_d3d11.c.obj mpv.exe.p/video_out_opengl_context_win.c.obj mpv.exe.p/video_out_opengl_context_dxinterop.c.obj mpv.exe.p/video_out_opengl_angle_dynamic.c.obj mpv.exe.p/video_out_opengl_context_angle.c.obj mpv.exe.p/video_out_gpu_d3d11_helpers.c.obj mpv.exe.p/video_out_opengl_egl_helpers.c.obj mpv.exe.p/video_out_opengl_common.c.obj mpv.exe.p/video_out_opengl_context.c.obj mpv.exe.p/video_out_opengl_formats.c.obj mpv.exe.p/video_out_opengl_libmpv_gl.c.obj mpv.exe.p/video_out_opengl_ra_gl.c.obj mpv.exe.p/video_out_opengl_utils.c.obj mpv.exe.p/video_out_vulkan_context.c.obj mpv.exe.p/video_out_vulkan_context_display.c.obj mpv.exe.p/video_out_vulkan_utils.c.obj mpv.exe.p/video_out_vulkan_context_win.c.obj mpv.exe.p/video_cuda.c.obj mpv.exe.p/video_out_hwdec_hwdec_cuda.c.obj mpv.exe.p/video_out_hwdec_hwdec_cuda_gl.c.obj mpv.exe.p/video_out_hwdec_hwdec_cuda_vk.c.obj mpv.exe.p/video_d3d.c.obj mpv.exe.p/video_filter_vf_d3d11vpp.c.obj mpv.exe.p/video_out_opengl_hwdec_d3d11egl.c.obj mpv.exe.p/video_out_d3d11_hwdec_d3d11va.c.obj mpv.exe.p/video_out_opengl_hwdec_dxva2egl.c.obj mpv.exe.p/video_out_d3d11_hwdec_dxva2dxgi.c.obj mpv.exe.p/video_out_opengl_hwdec_dxva2gldx.c.obj -o/home/ck/m/b/packages/mpv-prefix/src/mpv-build/mpv.exe -Wl,-Bstatic -L/home/ck/m/b/install/mingw/lib -ldvdcss -ldvdread -ldvdcss -ldvdnav -ldvdcss -ldvdread -ldvdcss -lavfilter -lbs2b -lmysofa -lass -lfontconfig -lexpat -lharfbuzz -lfribidi -lswscale -lpostproc -lavformat -lxml2 -lmodplug -lopenmpt -lrpcrt4 -lvorbisfile -lvsscript -lvapoursynth -lzimg -lbluray -lgdi32 -lfreetype -lbz2 -lpng16 -ludfread -lgmp -lsrt -ladvapi32 -lshell32 -lmingw32 -lmoldname -lmingwex -lkernel32 -lssh -lmbedtls -lmbedx509 -lmbedcrypto -lwsock32 -lws2_32 -lavcodec -lvpx -lwebpmux -liconv -llzma -ldav1d -laom -ljxl -lhwy -lbrotlienc -lbrotlidec -lbrotlicommon -llcms2 -lpthread -ljxl_threads -lmp3lame -lopus -lspeex -lvorbisenc -lvorbis -logg -lwebp -lx264 -lx265 -lgcc -lxvidcore -lmfuuid -lstrmiids -lz -lswresample -lsoxr -lavutil -lm -lmfx -lstdc++ -lole32 -luuid -luser32 -lbcrypt -latomic -lm -lmujs -lm -lavcodec -lvpx -lwebpmux -liconv -llzma -ldav1d -laom -ljxl -lhwy -lbrotlienc -lbrotlidec -lbrotlicommon -llcms2 -lpthread -ljxl_threads -lmp3lame -lopus -lspeex -lvorbisenc -lvorbis -logg -lwebp -lx264 -lx265 -lgcc -lxvidcore -lmfuuid -lstrmiids -lz -lswresample -lsoxr -lavutil -lm -lmfx -lstdc++ -lole32 -luuid -luser32 -lbcrypt -latomic -lm -lpthread -llcms2 -lm -lpthread -lexpat -llzo2 -llzma -lbz2 -lz -liconv -larchive -lexpat -llzo2 -llzma -lbz2 -lz -liconv -lbrotlicommon -lexpat -lm -lbrotlicommon -lbrotlicommon -lass -liconv -lgdi32 -lfontconfig -lbrotlicommon -lexpat -lharfbuzz -lm -lbrotlicommon -lfribidi -lfreetype -lbz2 -lpng16 -lz -lbrotlidec -lbrotlicommon -lm -lavdevice -lpsapi -lshlwapi -lvfw32 -lSDL2main -lSDL2 -lm -ldinput8 -ldxguid -ldxerr8 -lwinmm -limm32 -loleaut32 -lsetupapi -lversion -lavfilter -lbs2b -lmysofa -lass -lfontconfig -lexpat -lharfbuzz -lfribidi -lswscale -lpostproc -lavformat -lxml2 -lmodplug -lopenmpt -lrpcrt4 -lvorbisfile -lvsscript -lvapoursynth -lzimg -lbluray -lgdi32 -lfreetype -lbz2 -lpng16 -ludfread -lgmp -lsrt -ladvapi32 -lshell32 -lmingw32 -lmoldname -lmingwex -lkernel32 -lssh -lmbedtls -lmbedx509 -lmbedcrypto -lwsock32 -lws2_32 -lavcodec -lvpx -lwebpmux -liconv -llzma -ldav1d -laom -ljxl -lhwy -lbrotlienc -lbrotlidec -lbrotlicommon -llcms2 -lpthread -ljxl_threads -lmp3lame -lopus -lspeex -lvorbisenc -lvorbis -logg -lwebp -lx264 -lx265 -lgcc -lxvidcore -lmfuuid -lstrmiids -lz -lswresample -lsoxr -lavutil -lm -lmfx -lstdc++ -lole32 -luuid -luser32 -lbcrypt -latomic -lgdi32 -lfreetype -lbz2 -lpng16 -lz -lz -lz -lbrotlicommon -lbluray -lgdi32 -lfreetype -lbz2 -lpng16 -lz -lz -lz -lbrotlidec -lbrotlicommon -ludfread -lm -lpthread -lshlwapi -lcfgmgr32 -lplacebo -lm -lversion -llcms2 -lm -lpthread -lshaderc_combined -lvulkan -lshlwapi -lcfgmgr32 -lepoxy -lopengl32 -lgdi32 -lspirv-cross-c-shared -lm -liconv -lluajit-5.1 -lm -liconv -lwinmm -latomic -lm -lOpenAL32 -lwinmm -latomic -lm -lstdc++ -lrubberband -lstdc++ -lmingw32 -lSDL2main -lSDL2 -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid -lshaderc_combined -lspirv-cross-c-shared -lstdc++ -luchardet -lstdc++ -lzimg -lzimg -lstdc++ -lzimg -lzimg -lstdc++ -lzimg -lzimg -lstdc++ -lvsscript -lvapoursynth -lzimg -lzimg -lstdc++ -lshlwapi -lcfgmgr32 -lvulkan -lshlwapi -lcfgmgr32 -lstdc++ -lzimg -lstdc++ -lz -Wl,-Bdynamic -lopengl32 -liconv -ljpeg -lm -lwinmm -lgdi32 -lole32 -luuid -lavrt -ldwmapi -lversion -Wl,--major-os-version=6,--minor-os-version=0 -Wl,--major-subsystem-version=6,--minor-subsystem-version=0 -mwindows

Meson:

/home/ck/m/b/install/bin/x86_64-w64-mingw32-gcc -o mpv.exe osdep_mpv.rc_mpv.o mpv.exe.p/audio_aframe.c.obj mpv.exe.p/audio_chmap.c.obj mpv.exe.p/audio_chmap_sel.c.obj mpv.exe.p/audio_decode_ad_lavc.c.obj mpv.exe.p/audio_decode_ad_spdif.c.obj mpv.exe.p/audio_filter_af_drop.c.obj mpv.exe.p/audio_filter_af_format.c.obj mpv.exe.p/audio_filter_af_lavcac3enc.c.obj mpv.exe.p/audio_filter_af_scaletempo.c.obj mpv.exe.p/audio_filter_af_scaletempo2.c.obj mpv.exe.p/audio_filter_af_scaletempo2_internals.c.obj mpv.exe.p/audio_fmt-conversion.c.obj mpv.exe.p/audio_format.c.obj mpv.exe.p/audio_out_ao.c.obj mpv.exe.p/audio_out_ao_lavc.c.obj mpv.exe.p/audio_out_ao_null.c.obj mpv.exe.p/audio_out_ao_pcm.c.obj mpv.exe.p/audio_out_buffer.c.obj mpv.exe.p/common_av_common.c.obj mpv.exe.p/common_av_log.c.obj mpv.exe.p/common_codecs.c.obj mpv.exe.p/common_common.c.obj mpv.exe.p/common_encode_lavc.c.obj mpv.exe.p/common_msg.c.obj mpv.exe.p/common_playlist.c.obj mpv.exe.p/common_recorder.c.obj mpv.exe.p/common_stats.c.obj mpv.exe.p/common_tags.c.obj mpv.exe.p/common_version.c.obj mpv.exe.p/demux_codec_tags.c.obj mpv.exe.p/demux_cue.c.obj mpv.exe.p/demux_cache.c.obj mpv.exe.p/demux_demux.c.obj mpv.exe.p/demux_demux_cue.c.obj mpv.exe.p/demux_demux_disc.c.obj mpv.exe.p/demux_demux_edl.c.obj mpv.exe.p/demux_demux_lavf.c.obj mpv.exe.p/demux_demux_mf.c.obj mpv.exe.p/demux_demux_mkv.c.obj mpv.exe.p/demux_demux_mkv_timeline.c.obj mpv.exe.p/demux_demux_null.c.obj mpv.exe.p/demux_demux_playlist.c.obj mpv.exe.p/demux_demux_raw.c.obj mpv.exe.p/demux_demux_timeline.c.obj mpv.exe.p/demux_ebml.c.obj mpv.exe.p/demux_packet.c.obj mpv.exe.p/demux_timeline.c.obj mpv.exe.p/filters_f_async_queue.c.obj mpv.exe.p/filters_f_autoconvert.c.obj mpv.exe.p/filters_f_auto_filters.c.obj mpv.exe.p/filters_f_decoder_wrapper.c.obj mpv.exe.p/filters_f_demux_in.c.obj mpv.exe.p/filters_f_hwtransfer.c.obj mpv.exe.p/filters_f_lavfi.c.obj mpv.exe.p/filters_f_output_chain.c.obj mpv.exe.p/filters_f_swresample.c.obj mpv.exe.p/filters_f_swscale.c.obj mpv.exe.p/filters_f_utils.c.obj mpv.exe.p/filters_filter.c.obj mpv.exe.p/filters_frame.c.obj mpv.exe.p/filters_user_filters.c.obj mpv.exe.p/input_cmd.c.obj mpv.exe.p/input_event.c.obj mpv.exe.p/input_input.c.obj mpv.exe.p/input_ipc.c.obj mpv.exe.p/input_keycodes.c.obj mpv.exe.p/misc_bstr.c.obj mpv.exe.p/misc_charset_conv.c.obj mpv.exe.p/misc_dispatch.c.obj mpv.exe.p/misc_json.c.obj mpv.exe.p/misc_natural_sort.c.obj mpv.exe.p/misc_node.c.obj mpv.exe.p/misc_rendezvous.c.obj mpv.exe.p/misc_thread_pool.c.obj mpv.exe.p/misc_thread_tools.c.obj mpv.exe.p/options_m_config_core.c.obj mpv.exe.p/options_m_config_frontend.c.obj mpv.exe.p/options_m_option.c.obj mpv.exe.p/options_m_property.c.obj mpv.exe.p/options_options.c.obj mpv.exe.p/options_parse_commandline.c.obj mpv.exe.p/options_parse_configfile.c.obj mpv.exe.p/options_path.c.obj mpv.exe.p/player_audio.c.obj mpv.exe.p/player_client.c.obj mpv.exe.p/player_command.c.obj mpv.exe.p/player_configfiles.c.obj mpv.exe.p/player_external_files.c.obj mpv.exe.p/player_loadfile.c.obj mpv.exe.p/player_main.c.obj mpv.exe.p/player_misc.c.obj mpv.exe.p/player_osd.c.obj mpv.exe.p/player_playloop.c.obj mpv.exe.p/player_screenshot.c.obj mpv.exe.p/player_scripting.c.obj mpv.exe.p/player_sub.c.obj mpv.exe.p/player_video.c.obj mpv.exe.p/stream_cookies.c.obj mpv.exe.p/stream_stream.c.obj mpv.exe.p/stream_stream_avdevice.c.obj mpv.exe.p/stream_stream_cb.c.obj mpv.exe.p/stream_stream_concat.c.obj mpv.exe.p/stream_stream_edl.c.obj mpv.exe.p/stream_stream_file.c.obj mpv.exe.p/stream_stream_lavf.c.obj mpv.exe.p/stream_stream_memory.c.obj mpv.exe.p/stream_stream_mf.c.obj mpv.exe.p/stream_stream_null.c.obj mpv.exe.p/stream_stream_slice.c.obj mpv.exe.p/sub_ass_mp.c.obj mpv.exe.p/sub_dec_sub.c.obj mpv.exe.p/sub_draw_bmp.c.obj mpv.exe.p/sub_filter_sdh.c.obj mpv.exe.p/sub_img_convert.c.obj mpv.exe.p/sub_lavc_conv.c.obj mpv.exe.p/sub_osd.c.obj mpv.exe.p/sub_osd_libass.c.obj mpv.exe.p/sub_sd_ass.c.obj mpv.exe.p/sub_sd_lavc.c.obj mpv.exe.p/video_csputils.c.obj mpv.exe.p/video_decode_vd_lavc.c.obj mpv.exe.p/video_filter_refqueue.c.obj mpv.exe.p/video_filter_vf_format.c.obj mpv.exe.p/video_filter_vf_sub.c.obj mpv.exe.p/video_fmt-conversion.c.obj mpv.exe.p/video_hwdec.c.obj mpv.exe.p/video_image_loader.c.obj mpv.exe.p/video_image_writer.c.obj mpv.exe.p/video_img_format.c.obj mpv.exe.p/video_mp_image.c.obj mpv.exe.p/video_mp_image_pool.c.obj mpv.exe.p/video_out_aspect.c.obj mpv.exe.p/video_out_bitmap_packer.c.obj mpv.exe.p/video_out_dither.c.obj mpv.exe.p/video_out_dr_helper.c.obj mpv.exe.p/video_out_filter_kernels.c.obj mpv.exe.p/video_out_gpu_context.c.obj mpv.exe.p/video_out_gpu_error_diffusion.c.obj mpv.exe.p/video_out_gpu_hwdec.c.obj mpv.exe.p/video_out_gpu_lcms.c.obj mpv.exe.p/video_out_gpu_libmpv_gpu.c.obj mpv.exe.p/video_out_gpu_osd.c.obj mpv.exe.p/video_out_gpu_ra.c.obj mpv.exe.p/video_out_gpu_shader_cache.c.obj mpv.exe.p/video_out_gpu_spirv.c.obj mpv.exe.p/video_out_gpu_user_shaders.c.obj mpv.exe.p/video_out_gpu_utils.c.obj mpv.exe.p/video_out_gpu_video.c.obj mpv.exe.p/video_out_gpu_video_shaders.c.obj mpv.exe.p/video_out_libmpv_sw.c.obj mpv.exe.p/video_out_vo.c.obj mpv.exe.p/video_out_vo_gpu.c.obj mpv.exe.p/video_out_vo_image.c.obj mpv.exe.p/video_out_vo_lavc.c.obj mpv.exe.p/video_out_vo_libmpv.c.obj mpv.exe.p/video_out_vo_null.c.obj mpv.exe.p/video_out_vo_tct.c.obj mpv.exe.p/video_out_win_state.c.obj mpv.exe.p/video_repack.c.obj mpv.exe.p/video_sws_utils.c.obj mpv.exe.p/osdep_io.c.obj mpv.exe.p/osdep_semaphore_osx.c.obj mpv.exe.p/osdep_subprocess.c.obj mpv.exe.p/osdep_threads.c.obj mpv.exe.p/osdep_timer.c.obj mpv.exe.p/ta_ta.c.obj mpv.exe.p/ta_ta_talloc.c.obj mpv.exe.p/ta_ta_utils.c.obj mpv.exe.p/osdep_win32_pthread.c.obj mpv.exe.p/osdep_timer-win2.c.obj mpv.exe.p/osdep_w32_keyboard.c.obj mpv.exe.p/osdep_windows_utils.c.obj mpv.exe.p/input_ipc-win.c.obj mpv.exe.p/osdep_main-fn-win.c.obj mpv.exe.p/osdep_path-win.c.obj mpv.exe.p/osdep_subprocess-win.c.obj mpv.exe.p/osdep_terminal-win.c.obj mpv.exe.p/video_out_w32_common.c.obj mpv.exe.p/video_out_win32_displayconfig.c.obj mpv.exe.p/video_out_win32_droptarget.c.obj mpv.exe.p/osdep_glob-win.c.obj mpv.exe.p/player_javascript.c.obj mpv.exe.p/sub_filter_jsre.c.obj mpv.exe.p/demux_demux_libarchive.c.obj mpv.exe.p/stream_stream_libarchive.c.obj mpv.exe.p/stream_stream_bluray.c.obj mpv.exe.p/player_lua.c.obj mpv.exe.p/audio_filter_af_rubberband.c.obj mpv.exe.p/input_sdl_gamepad.c.obj mpv.exe.p/video_filter_vf_vapoursynth.c.obj mpv.exe.p/video_filter_vf_fingerprint.c.obj mpv.exe.p/video_zimg.c.obj mpv.exe.p/audio_out_ao_openal.c.obj mpv.exe.p/audio_out_ao_sdl.c.obj mpv.exe.p/audio_out_ao_wasapi.c.obj mpv.exe.p/audio_out_ao_wasapi_changenotify.c.obj mpv.exe.p/audio_out_ao_wasapi_utils.c.obj mpv.exe.p/video_out_vo_direct3d.c.obj mpv.exe.p/video_out_placebo_ra_pl.c.obj mpv.exe.p/video_out_placebo_utils.c.obj mpv.exe.p/video_out_vo_gpu_next.c.obj mpv.exe.p/video_out_gpu_next_context.c.obj mpv.exe.p/video_out_vo_sdl.c.obj mpv.exe.p/video_out_gpu_spirv_shaderc.c.obj mpv.exe.p/video_out_d3d11_context.c.obj mpv.exe.p/video_out_d3d11_ra_d3d11.c.obj mpv.exe.p/video_out_opengl_context_win.c.obj mpv.exe.p/video_out_opengl_context_dxinterop.c.obj mpv.exe.p/video_out_opengl_angle_dynamic.c.obj mpv.exe.p/video_out_opengl_context_angle.c.obj mpv.exe.p/video_out_gpu_d3d11_helpers.c.obj mpv.exe.p/video_out_opengl_egl_helpers.c.obj mpv.exe.p/video_out_opengl_common.c.obj mpv.exe.p/video_out_opengl_context.c.obj mpv.exe.p/video_out_opengl_formats.c.obj mpv.exe.p/video_out_opengl_libmpv_gl.c.obj mpv.exe.p/video_out_opengl_ra_gl.c.obj mpv.exe.p/video_out_opengl_utils.c.obj mpv.exe.p/video_out_vulkan_context.c.obj mpv.exe.p/video_out_vulkan_context_display.c.obj mpv.exe.p/video_out_vulkan_utils.c.obj mpv.exe.p/video_out_vulkan_context_win.c.obj mpv.exe.p/video_cuda.c.obj mpv.exe.p/video_out_hwdec_hwdec_cuda.c.obj mpv.exe.p/video_out_hwdec_hwdec_cuda_gl.c.obj mpv.exe.p/video_out_hwdec_hwdec_cuda_vk.c.obj mpv.exe.p/video_d3d.c.obj mpv.exe.p/video_filter_vf_d3d11vpp.c.obj mpv.exe.p/video_out_opengl_hwdec_d3d11egl.c.obj mpv.exe.p/video_out_d3d11_hwdec_d3d11va.c.obj mpv.exe.p/video_out_opengl_hwdec_dxva2egl.c.obj mpv.exe.p/video_out_d3d11_hwdec_dxva2dxgi.c.obj mpv.exe.p/video_out_opengl_hwdec_dxva2gldx.c.obj -flto -Wl,--allow-shlib-undefined -Wl,-O1 -Wl,--nxcompat,--no-seh,--dynamicbase -Wl,--start-group /home/ck/m/b/install/mingw/lib/libavutil.a -lm /home/ck/m/b/install/mingw/lib/libmfx.a /home/ck/m/b/install/mingw/lib/libstdc++.a /home/ck/m/b/install/mingw/lib/libole32.a /home/ck/m/b/install/mingw/lib/libuuid.a /home/ck/m/b/install/mingw/lib/libuser32.a /home/ck/m/b/install/mingw/lib/libbcrypt.a /home/ck/m/b/install/mingw/lib/libatomic.a /home/ck/m/b/install/mingw/lib/libavcodec.a /home/ck/m/b/install/mingw/lib/libvpx.a /home/ck/m/b/install/mingw/lib/libwebpmux.a /home/ck/m/b/install/mingw/lib/libiconv.a /home/ck/m/b/install/mingw/lib/liblzma.a /home/ck/m/b/install/mingw/lib/libdav1d.a /home/ck/m/b/install/mingw/lib/libaom.a /home/ck/m/b/install/mingw/lib/libjxl.a /home/ck/m/b/install/mingw/lib/libhwy.a /home/ck/m/b/install/mingw/lib/libbrotlienc.a /home/ck/m/b/install/mingw/lib/libbrotlidec.a /home/ck/m/b/install/mingw/lib/libbrotlicommon.a /home/ck/m/b/install/mingw/lib/liblcms2.a -lpthread /home/ck/m/b/install/mingw/lib/libjxl_threads.a /home/ck/m/b/install/mingw/lib/libmp3lame.a /home/ck/m/b/install/mingw/lib/libopus.a /home/ck/m/b/install/mingw/lib/libspeex.a /home/ck/m/b/install/mingw/lib/libvorbisenc.a /home/ck/m/b/install/mingw/lib/libvorbis.a /home/ck/m/b/install/mingw/lib/libogg.a /home/ck/m/b/install/mingw/lib/libwebp.a /home/ck/m/b/install/mingw/lib/libx264.a /home/ck/m/b/install/mingw/lib/libx265.a /home/ck/m/b/install/lib/gcc/x86_64-w64-mingw32/12.1.0/libgcc.a /home/ck/m/b/install/mingw/lib/libxvidcore.a /home/ck/m/b/install/mingw/lib/libmfuuid.a /home/ck/m/b/install/mingw/lib/libstrmiids.a /home/ck/m/b/install/mingw/lib/libz.a /home/ck/m/b/install/mingw/lib/libswresample.a /home/ck/m/b/install/mingw/lib/libsoxr.a /home/ck/m/b/install/mingw/lib/libavformat.a /home/ck/m/b/install/mingw/lib/libxml2.a /home/ck/m/b/install/mingw/lib/libmodplug.a /home/ck/m/b/install/mingw/lib/libopenmpt.a /home/ck/m/b/install/mingw/lib/librpcrt4.a /home/ck/m/b/install/mingw/lib/libvorbisfile.a /home/ck/m/b/install/mingw/lib/libvsscript.a /home/ck/m/b/install/mingw/lib/libvapoursynth.a /home/ck/m/b/install/mingw/lib/libzimg.a /home/ck/m/b/install/mingw/lib/libbluray.a /home/ck/m/b/install/mingw/lib/libgdi32.a /home/ck/m/b/install/mingw/lib/libfreetype.a /home/ck/m/b/install/mingw/lib/libbz2.a /home/ck/m/b/install/mingw/lib/libpng16.a /home/ck/m/b/install/mingw/lib/libudfread.a /home/ck/m/b/install/mingw/lib/libgmp.a /home/ck/m/b/install/mingw/lib/libsrt.a /home/ck/m/b/install/mingw/lib/libadvapi32.a /home/ck/m/b/install/mingw/lib/libshell32.a /home/ck/m/b/install/mingw/lib/libmingw32.a /home/ck/m/b/install/mingw/lib/libmoldname.a /home/ck/m/b/install/mingw/lib/libmingwex.a /home/ck/m/b/install/mingw/lib/libkernel32.a /home/ck/m/b/install/mingw/lib/libssh.a /home/ck/m/b/install/mingw/lib/libmbedtls.a /home/ck/m/b/install/mingw/lib/libmbedx509.a /home/ck/m/b/install/mingw/lib/libmbedcrypto.a /home/ck/m/b/install/mingw/lib/libwsock32.a /home/ck/m/b/install/mingw/lib/libws2_32.a /home/ck/m/b/install/mingw/lib/libswscale.a /home/ck/m/b/install/mingw/lib/libavfilter.a /home/ck/m/b/install/mingw/lib/libbs2b.a /home/ck/m/b/install/mingw/lib/libmysofa.a /home/ck/m/b/install/mingw/lib/libass.a /home/ck/m/b/install/mingw/lib/libfontconfig.a /home/ck/m/b/install/mingw/lib/libexpat.a /home/ck/m/b/install/mingw/lib/libharfbuzz.a /home/ck/m/b/install/mingw/lib/libfribidi.a /home/ck/m/b/install/mingw/lib/libpostproc.a -pthread -lavrt -ldwmapi -lgdi32 -lole32 -luuid -lversion -lwinmm -liconv /home/ck/m/b/install/mingw/lib/libmujs.a /home/ck/m/b/install/mingw/lib/libarchive.a /home/ck/m/b/install/mingw/lib/libavdevice.a /home/ck/m/b/install/mingw/lib/libpsapi.a /home/ck/m/b/install/mingw/lib/libshlwapi.a /home/ck/m/b/install/mingw/lib/libvfw32.a /home/ck/m/b/install/mingw/lib/libSDL2main.a /home/ck/m/b/install/mingw/lib/libSDL2.a -Wl,--dynamicbase -Wl,--nxcompat -Wl,--high-entropy-va /home/ck/m/b/install/mingw/lib/libdinput8.a /home/ck/m/b/install/mingw/lib/libdxguid.a /home/ck/m/b/install/mingw/lib/libdxerr8.a /home/ck/m/b/install/mingw/lib/libwinmm.a /home/ck/m/b/install/mingw/lib/libimm32.a /home/ck/m/b/install/mingw/lib/liboleaut32.a /home/ck/m/b/install/mingw/lib/libsetupapi.a /home/ck/m/b/install/mingw/lib/libversion.a /home/ck/m/b/install/mingw/lib/libluajit-5.1.a /home/ck/m/b/install/mingw/lib/librubberband.a -mwindows -Wl,--dynamicbase -Wl,--nxcompat -Wl,--high-entropy-va -latomic /home/ck/m/b/install/mingw/lib/libuchardet.a /home/ck/m/b/install/mingw/lib/libOpenAL32.a /home/ck/m/b/install/mingw/lib/libjpeg.a /home/ck/m/b/install/mingw/lib/libplacebo.a /home/ck/m/b/install/mingw/lib/libshaderc_combined.a /home/ck/m/b/install/mingw/lib/libvulkan.a /home/ck/m/b/install/mingw/lib/libepoxy.a /home/ck/m/b/install/mingw/lib/libopengl32.a /home/ck/m/b/install/mingw/lib/libspirv-cross-c-shared.a -lopengl32 -Wl,--subsystem,windows:6.0 -lkernel32 -luser32 -lwinspool -lshell32 -loleaut32 -lcomdlg32 -ladvapi32 -Wl,--end-group

The main difference here is that waf uses the -lXXX syntax while Meson directly specify the .a files. And if I replace those .a files with waf's -ls, the Meson's command will work.

I wonder if there is a way to change Meson.

@shinchiro
Copy link
Owner

Try to put -Dc_link_args='-lfontconfig' in configure. Does it fix the problem?

--prefer-static
-Db_lto=true
-Db_ndebug=true
-Dlibmpv=true

@CrendKing
Copy link
Author

Doing that will put a -lfontconfig at the front of all the libraries, which is good idea. However, that itself will not suffice. -lass is also needed to make it work.

Then, I was thinking, gcc's -l is just syntax sugar to avoid specifying the full filename. So the important difference must be the ordering of the libraries. After trial and error, I found that if I place libass.a and libfontconfig.a BEFORE libmingwex.a, it will start to work. Which makes sense, because libmingwex.a is the one exporting opendir. As to why there must be that order, I still have no idea.

Finally, how to elegantly fix this? Sure, we can just add the -Dc_link_args, but what about fixing the meson.build itself? If we swap ffmpeg['deps'] (which brings in libmingwex) and libass at https://github.com/mpv-player/mpv/blob/602995fd40f03440f5fa64113b6188cb46ffcc9c/meson.build#L31, the whole thing works again.

Now, I think we have three options: 1) two -Dc_link_args; 2) make a little patch to swap the positions; 3) Create PR in mpv. What do you guys prefer?

@shinchiro
Copy link
Owner

Well, better create issue in mpv and linked back to this issue. Using -Dc_link_args is not long-term solution btw

@CrendKing
Copy link
Author

CrendKing commented Jun 15, 2022

Dudemanguy pushed a commit to mpv-player/mpv that referenced this issue Jun 18, 2022
In win32 build, if libass and libfontconfig appear after libmingwex
during linking, crash happens whenever fontconfig calls to opendir().

Moving them before ffmpeg makes sure they always appear first.

More info on shinchiro/mpv-winbuild-cmake#217.
dyphire pushed a commit to dyphire/mpv-winbuild-cmake that referenced this issue Jun 21, 2022
as temporary fix for problem in shinchiro#217
dyphire pushed a commit to dyphire/mpv-winbuild-cmake that referenced this issue Jun 21, 2022
as temporary fix for problem in shinchiro#217
dyphire pushed a commit to dyphire/mpv-winbuild-cmake that referenced this issue Jun 25, 2022
as temporary fix for problem in shinchiro#217
dyphire pushed a commit to dyphire/mpv that referenced this issue Feb 22, 2023
In win32 build, if libass and libfontconfig appear after libmingwex
during linking, crash happens whenever fontconfig calls to opendir().

Moving them before ffmpeg makes sure they always appear first.

More info on shinchiro/mpv-winbuild-cmake#217.
dyphire pushed a commit to dyphire/mpv that referenced this issue Feb 22, 2023
In win32 build, if libass and libfontconfig appear after libmingwex
during linking, crash happens whenever fontconfig calls to opendir().

Moving them before ffmpeg makes sure they always appear first.

More info on shinchiro/mpv-winbuild-cmake#217.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants