microsoft / wslg

Enabling the Windows Subsystem for Linux to include support for Wayland and X server related scenarios
MIT License
10.25k stars 307 forks source link

[d3d12][WSLg] d3d12_fence_finish() null pointer dereference in mesa #1131

Open kasper93 opened 1 year ago

kasper93 commented 1 year ago

Windows build number:

10.0.22621.0

Your Distribution version:

Kali GNU/Linux 2023.3

Your WSL versions:

WSL version: 2.0.7.0
Kernel version: 5.15.133.1-1
WSLg version: 1.0.59
MSRDC version: 1.2.4677
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25880.1000-230602-1350.main
Windows version: 10.0.22621.2506

Steps to reproduce:

  1. mpv --no-config --vo=gpu-next
  2. wait for ~40s

WSL logs:

No response

WSL dumps:

No response

Expected behavior:

No crash.

Actual behavior:

I initially reported on mesa's issue tracker, as the crash itself is in mesa, but I'm not sure you monitor the WSLg issues there, so I decided to share the report also here. See for more info: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9845

The mesa crash is only a product what looks like issue in kernel dxgkio_wait_sync_object_cpu: failed to reference the event which later triggers the null ptr deref in mesa. See below for backtrack and dmesg message.

mpv crashes during playback. Happens after some time, usually ~40s more or less. fence_finish is called with pfence=0x0. mpv --no-config --vo=gpu-next <file> to reproduce

Thread 42 "mpv/vo" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffed5a646c0 (LWP 32000)]
fence_finish (pscreen=0x7ffec00ade80, pctx=0x7ffec07046b0, pfence=0x0, timeout_ns=18446744073709551615) at ../src/gallium/drivers/d3d12/d3d12_fence.cpp:128
128        bool ret = d3d12_fence_finish(d3d12_fence(pfence), timeout_ns);
(gdb) bt
#0  fence_finish(pipe_screen*, pipe_context*, pipe_fence_handle*, uint64_t) (pscreen=0x7ffec00ade80, pctx=0x7ffec07046b0, pfence=0x0, timeout_ns=18446744073709551615)
    at ../src/gallium/drivers/d3d12/d3d12_fence.cpp:128
#1  0x00007ffed43da12a in drisw_swap_buffers (drawable=0x7ffec07f8d30) at ../src/gallium/frontends/dri/drisw.c:255
#2  0x00007ffff4afb66b in dri2_wl_swrast_swap_buffers (disp=0x7ffec004dff0, draw=0x7ffec07f8860) at ../src/egl/drivers/dri2/platform_wayland.c:2626
#3  0x00007ffff4af3013 in dri2_swap_buffers (disp=0x7ffec004dff0, surf=0x7ffec07f8860) at ../src/egl/drivers/dri2/egl_dri2.c:1890
#4  0x00007ffff4ae379d in eglSwapBuffers (dpy=<optimized out>, surface=0x7ffec07f8860) at ../src/egl/main/eglapi.c:1436
#5  0x00005555556a428f in wayland_egl_swap_buffers (ctx=<optimized out>) at ../video/out/opengl/context_wayland.c:70
#6  0x00005555556a6d6b in ra_gl_ctx_swap_buffers (sw=0x7ffec07909b0) at ../video/out/opengl/context.c:292
#7  0x000055555566a4d8 in render_frame (vo=0x5555558cac20) at ../video/out/vo.c:983
#8  vo_thread (ptr=0x5555558cac20) at ../video/out/vo.c:1117
#9  0x00007ffff46a63dc in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:444
#10 0x00007ffff4726a1c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

Start of playback @ 182s and crash @ 224s.

[  182.029388] misc dxg: dxgk: dxgkio_query_adapter_info: Ioctl failed: -22
[  182.029670] misc dxg: dxgk: dxgkio_query_adapter_info: Ioctl failed: -22
[  182.029860] misc dxg: dxgk: dxgkio_query_adapter_info: Ioctl failed: -22
[  182.030159] misc dxg: dxgk: dxgkio_query_adapter_info: Ioctl failed: -2
[  224.206339] misc dxg: dxgk: dxgkio_wait_sync_object_cpu: failed to reference the event
[  224.206610] misc dxg: dxgk: dxgkio_wait_sync_object_cpu: Ioctl failed: -22