LizardByte / Sunshine

Self-hosted game stream host for Moonlight.
http://app.lizardbyte.dev/Sunshine/
GNU General Public License v3.0
19.47k stars 947 forks source link

Segfault after loading EGL library fails #1874

Closed Nemo157 closed 11 months ago

Nemo157 commented 11 months ago

Is there an existing issue for this?

Is your issue described in the documentation?

Is your issue present in the nightly release?

Describe the Bug

After loading the EGL library fails, Sunshine segfaults calling an EGL function while attempting to test encoders

Expected Behavior

If the library fails loading, it's not attempted to be used later

Additional Context

(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00000000005c9f44 in egl::make_display (native_display=std::variant<> [no contained value]) at /build/source/src/platform/linux/graphics.cpp:367
#2  0x00000000005a1871 in wl::wlr_ram_t::init (config=..., display_name="", hwdevice_type=platf::mem_type_e::cuda, this=0x1a2d490)
    at /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-gcc-12.3.0/include/c++/12.3.0/bits/enable_special_members.h:67
#3  platf::wl_display (hwdevice_type=hwdevice_type@entry=platf::mem_type_e::cuda, display_name="", config=...) at /build/source/src/platform/linux/wlgrab.cpp:372
#4  0x00000000005ce99a in platf::display (hwdevice_type=platf::mem_type_e::cuda, display_name="", config=...) at /build/source/src/platform/linux/misc.cpp:704
#5  0x00000000005547ec in video::reset_display (disp=std::shared_ptr<platf::display_t> (empty) = {...}, type=@0x19f9948: platf::mem_type_e::cuda, display_name="", config=...)
    at /build/source/src/video.cpp:1006
#6  0x000000000055c5c0 in video::validate_encoder (encoder=..., expect_failure=expect_failure@entry=false) at /build/source/src/video.cpp:2276
#7  0x000000000055e092 in video::probe_encoders () at /build/source/src/video.cpp:2524
#8  0x0000000000456053 in main (argc=<optimized out>, argv=<optimized out>) at /build/source/src/main.cpp:746
(gdb) f 1
#1  0x00000000005c9f44 in egl::make_display (native_display=std::variant<> [no contained value]) at /build/source/src/platform/linux/graphics.cpp:367
Downloading source file /build/source/src/platform/linux/graphics.cpp
367         display_t display = eglGetPlatformDisplay(egl_platform, native_display_p, nullptr);

Host Operating System

Linux

Operating System Version

nixos 23.11

Architecture

64 bit

Sunshine commit or version

336062d467d5f48ba56d05a523c212f791421108

Package

Linux - nixpkgs (Third Party)

GPU Type

Nvidia

GPU Model

NVIDIA GeForce RTX 2070

GPU Driver/Mesa Version

545.29.02

Capture Method (Linux Only)

No response

Config

min_log_level = 2

Apps

No response

Relevant log output

[min_log_level] -- [2]
[2023:12:01:01:02:24]: Info: Sunshine version: 0.21.0
[2023:12:01:01:02:24]: Info: Found display [wayland-1]
[2023:12:01:01:02:24]: Info: Found interface: zwlr_export_dmabuf_manager_v1(7) version 1
[2023:12:01:01:02:24]: Info: Found interface: zxdg_output_manager_v1(49) version 3
[2023:12:01:01:02:24]: Info: Found interface: wl_output(50) version 4
[2023:12:01:01:02:24]: Info: Name: HDMI-A-1
[2023:12:01:01:02:24]: Info: Found monitor: Optoma Corporation Optoma 1080P Q72J6480359 (HDMI-A-1)
[2023:12:01:01:02:24]: Info: Offset: 0x0
[2023:12:01:01:02:24]: Info: Resolution: 1920x1080
[2023:12:01:01:02:24]: Error: Failed to gain CAP_SYS_ADMIN
[2023:12:01:01:02:24]: Error: Failed to gain CAP_SYS_ADMIN
[2023:12:01:01:02:24]: Error: Couldn't get handle for DRM Framebuffer [110]: Possibly not permitted: do [sudo setcap cap_sys_admin+p sunshine]
[2023:12:01:01:02:24]: Info: Found display [wayland-1]
[2023:12:01:01:02:24]: Info: Found display [wayland-1]
[2023:12:01:01:02:24]: Info: Found interface: zwlr_export_dmabuf_manager_v1(7) version 1
[2023:12:01:01:02:24]: Info: Found interface: zxdg_output_manager_v1(49) version 3
[2023:12:01:01:02:24]: Info: Found interface: wl_output(50) version 4
[2023:12:01:01:02:25]: Info: Name: HDMI-A-1
[2023:12:01:01:02:25]: Info: Found monitor: Optoma Corporation Optoma 1080P Q72J6480359 (HDMI-A-1)
[2023:12:01:01:02:25]: Info: Offset: 0x0
[2023:12:01:01:02:25]: Info: Resolution: 1920x1080
[2023:12:01:01:02:25]: Info: HDMI-A-1: Optoma Corporation Optoma 1080P Q72J6480359 (HDMI-A-1)
[2023:12:01:01:02:25]: Warning: Mismatch on expected Resolution compared to actual resolution: 0x0 vs 1920x1080
[2023:12:01:01:02:25]: Warning: Couldn't load EGL library
[2023:12:01:01:02:25]: Info: // Testing for available encoders, this may generate errors. You can safely ignore those errors. //
[2023:12:01:01:02:25]: Info: Trying encoder [nvenc]
[2023:12:01:01:02:25]: Info: Screencasting with Wayland's protocol
[2023:12:01:01:02:25]: Info: Found display [wayland-1]
[2023:12:01:01:02:25]: Info: Found interface: zwlr_export_dmabuf_manager_v1(7) version 1
[2023:12:01:01:02:25]: Info: Found interface: zxdg_output_manager_v1(49) version 3
[2023:12:01:01:02:25]: Info: Found interface: wl_output(50) version 4
[2023:12:01:01:02:25]: Info: Name: HDMI-A-1
[🡕] Process 722833 (sunshine) of user 1000 dumped core.
ReenigneArcher commented 11 months ago

I think you should move this issue to https://github.com/NixOS/nixpkgs

Nemo157 commented 11 months ago

The issue isn't that the library fails to load (I'm still attempting to debug why that is and fix it, I do assume that is a packaging issue). It's that after it occurs Sunshine segfaults. If loading the library is necessary for it to continue then that should be an error log and Sunshine should exit.

ReenigneArcher commented 11 months ago

I believe https://github.com/NixOS/nixpkgs/pull/271352 will fix this for you.