moonlight-qt icon indicating copy to clipboard operation
moonlight-qt copied to clipboard

segfault - FFmpeg attempts to load nvcuvid while using AMD card

Open SeaMonkey82 opened this issue 1 year ago • 10 comments

Attempted to join the Discord first, but encountered an endless loop of captchas, so posting here.

Describe the bug When attempting to run manually compiled moonlight client with an AMD card, the client segfaults when FFmpeg attempts to load nvcuvid.

Client PC details (please complete the following information)

  • OS: Linux Mint 21.2
  • Moonlight Version: 5.0.1
  • GPU: AMD Radeon RX 6900XT

Server PC details (please complete the following information)

  • OS: Windows 10 22H2
  • Nvidia GPU driver: 546.29
  • Antivirus and firewall software: Windows Defender and Windows Firewall

Moonlight Logs (please attach) moonlight_segfault.log

Additional context This error does not occur when running the AppImage release on the same hardware.

SeaMonkey82 avatar Dec 06 '23 23:12 SeaMonkey82

Where did you install Moonlight from? It looks like you're running with SDL 2.0.20 which is quite old and shouldn't be packaged in any of our official Flatpak or AppImages.

cgutman avatar Dec 07 '23 02:12 cgutman

Where did you install Moonlight from?

manually compiled moonlight

SeaMonkey82 avatar Dec 07 '23 07:12 SeaMonkey82

I manually installed the latest version of SDL, but make still seems to be using the one provided by the package manager, and I'm not sure what the correct way is to get make release to use the newer libraries. This didn't seem to work:

PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" LDFLAGS="-L/usr/local/lib" CFLAGS="-I/usr/local/include" make release

SeaMonkey82 avatar Dec 09 '23 01:12 SeaMonkey82

I ended up adding this PPA, which includes a more recent version of SDL. Compiled again, and Moonlight works!

https://launchpad.net/~savoury1/+archive/ubuntu/multimedia/

SeaMonkey82 avatar Dec 09 '23 02:12 SeaMonkey82

I move to re-open this issue, and find the exact cause. This also happens to me on Wayland/Hyprland on NixOS-unstable. I have the latest package as of writing, and SDL2 is at 2.28.5.

Here is a link to the derivation: https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/misc/moonlight-qt/default.nix

And I have attached a log of the exact events leading to a segfault. moonlight-log.txt

spikespaz avatar Dec 31 '23 18:12 spikespaz

Moonlight doesn't directly use nvcuvid. It's FFmpeg that's doing that.

To diagnose it, it would be helpful to run Moonlight under gdb and get a back trace of the crash.

cgutman avatar Dec 31 '23 21:12 cgutman

00:00:17 - FFmpeg: [h264_mp4toannexb @ 0x7fff60f74280] The input looks like it is Annex B already
00:00:17 - FFmpeg: [h264_cuvid @ 0x7fff604fd180] Format nv12 chosen by get_format().
00:00:17 - FFmpeg: [h264_cuvid @ 0x7fff604fd180] Cannot load libnvcuvid.so.1
00:00:17 - FFmpeg: [h264_cuvid @ 0x7fff604fd180] Failed loading nvcuvid.
00:00:17 - SDL Error (0): Unable to open decoder for format: 1
[Thread 0x7fff0b7fe6c0 (LWP 166191) exited]
[Thread 0x7fff10ff96c0 (LWP 166190) exited]
[Thread 0x7fff097fa6c0 (LWP 166189) exited]
[Thread 0x7fff117fa6c0 (LWP 166188) exited]
00:00:17 - SDL Info (0): Opened DRM render node: /dev/dri/renderD128
00:00:17 - SDL Info (0): GPU driver: amdgpu
00:00:17 - SDL Info (0): Direct rendering via DRM is disabled
[New Thread 0x7fff117fa6c0 (LWP 166192)]
[New Thread 0x7fff097fa6c0 (LWP 166193)]
00:00:17 - SDL Info (0): Using DRM renderer
00:00:17 - FFmpeg: [h264_mp4toannexb @ 0x7fff60f2ec00] The input looks like it is Annex B already
00:00:17 - FFmpeg: [h264_cuvid @ 0x7fff604fd180] Format nv12 chosen by get_format().
00:00:17 - FFmpeg: [h264_cuvid @ 0x7fff604fd180] Cannot load libnvcuvid.so.1
00:00:17 - FFmpeg: [h264_cuvid @ 0x7fff604fd180] Failed loading nvcuvid.
00:00:17 - SDL Error (0): Unable to open decoder for format: 1
[Thread 0x7fff097fa6c0 (LWP 166193) exited]
[Thread 0x7fff117fa6c0 (LWP 166192) exited]
00:00:17 - SDL Warn (0): No renderer can handle output from decoder: h264_cuvid
VA error: wayland: Wayland roundtrip error: Protocol error (errno 71)
libva info: VA-API version 1.20.0

Thread 73 "Session Exec" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fff5ffff6c0 (LWP 165953)]
0x00007ffff6094c7c in VA_DRM_GetDriverNames ()
   from /nix/store/lq4i5aq9r2biihfw7hy2ibvdxpq6402r-libva-2.20.0/lib/libva-wayland.so.2
(gdb)

I don't know anything about this, hope I did it right

spikespaz avatar Dec 31 '23 21:12 spikespaz

was that the full output of the bt command?

cgutman avatar Jan 01 '24 03:01 cgutman

@spikespaz are you still seeing this with the latest NixOS updates? I think the VA_DRM_GetDriverNames() crash was addressed in libva 1.21.0

cgutman avatar Apr 06 '24 20:04 cgutman

@cgutman

00:00:01 - SDL Info (0): Initialized VAAPI 1.21
00:00:01 - SDL Info (0): Driver: Mesa Gallium driver 24.0.3 for AMD Radeon Graphics (radeonsi, gfx1103_r1, LLVM 17.0.6, DRM 3.54, 6.6.24)
00:00:01 - SDL Warn (0): VAAPI driver is affected by RFI latency bug
00:00:01 - SDL Warn (0): Deprioritizing VAAPI on Gallium driver. Set FORCE_VAAPI=1 to override.
libva info: VA-API version 1.21.0
libva info: Trying to open /run/opengl-driver/lib/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_1_21
libva info: va_openDriver() returns 0
00:00:01 - SDL Info (0): Initialized VAAPI 1.21
00:00:01 - SDL Info (0): Driver: Mesa Gallium driver 24.0.3 for AMD Radeon Graphics (radeonsi, gfx1103_r1, LLVM 17.0.6, DRM 3.54, 6.6.24)
00:00:01 - SDL Warn (0): VAAPI driver is affected by RFI latency bug
00:00:01 - SDL Warn (0): Deprioritizing VAAPI on Gallium driver. Set FORCE_VAAPI=1 to override.
00:00:01 - SDL Warn (0): VDPAU is not supported on Wayland
00:00:01 - SDL Warn (0): VDPAU is not supported on Wayland
00:00:01 - SDL Info (0): Trying SdlRenderer for codec hevc_cuvid due to preferred pixel format: 0x9f
00:00:01 - SDL Info (0): Trying DrmRenderer for codec hevc_cuvid due to compatible pixel format: 0x17
00:00:01 - SDL Info (0): Opened DRM render node: /dev/dri/renderD128
00:00:01 - SDL Info (0): GPU driver: amdgpu
00:00:01 - SDL Info (0): Direct rendering via DRM is disabled
00:00:01 - SDL Info (0): DRM backend supports exporting EGLImage
00:00:01 - SDL Info (0): Color buffer is: R8G8B8A0
00:00:01 - SDL Info (0): EGL passed preflight checks. Using EGL for GL context creation.
00:00:01 - SDL Info (0): Using DRM renderer
00:00:01 - FFmpeg: [hevc_mp4toannexb @ 0x7ff1809f1e00] The input looks like it is Annex B already
00:00:01 - FFmpeg: [hevc_cuvid @ 0x7ff140038a80] Format nv12 chosen by get_format().
00:00:01 - FFmpeg: [hevc_cuvid @ 0x7ff140038a80] Cannot load libnvcuvid.so.1
00:00:01 - FFmpeg: [hevc_cuvid @ 0x7ff140038a80] Failed loading nvcuvid.
00:00:01 - SDL Error (0): Unable to open decoder for format: 200
00:00:01 - SDL Info (0): Opened DRM render node: /dev/dri/renderD128
00:00:01 - SDL Info (0): GPU driver: amdgpu
00:00:01 - SDL Info (0): Direct rendering via DRM is disabled
00:00:01 - SDL Info (0): Trying SdlRenderer for codec hevc_cuvid due to compatible pixel format: 0x17
00:00:01 - SDL Info (0): Trying DrmRenderer for codec hevc_cuvid due to compatible pixel format: 0x9f
00:00:01 - SDL Info (0): Opened DRM render node: /dev/dri/renderD128

Perhaps it is crashing due to other reasons, attach full log moonlight-log.txt

spikespaz avatar Apr 07 '24 15:04 spikespaz