loki-47-6F-64 / sunshine

Host for Moonlight Streaming Client
GNU General Public License v3.0
1.77k stars 154 forks source link

Ubuntu 21.10 - AMD V520 - Segmentation fault on start #285

Open sergioperez opened 2 years ago

sergioperez commented 2 years ago

Hello!

I've found that Sunshine is crashing with a Segmentation fault in the hardware I'm trying to run it at (AWS g4ad instances)

The logs in debug mode with a backtrace are:

GNU gdb (Ubuntu 11.1-0ubuntu2) 11.1
Copyright (C) 2021 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-linux-gnu".
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 ./sunshine...
[?2004h(gdb) run
[?2004l
Starting program: /home/ubuntu/sunshine/build/sunshine /etc/sunshine/sunshine.conf
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[min_log_level] -- [debug]
[New Thread 0x7fffef1cb640 (LWP 15897)]
[New Thread 0x7fffee9ca640 (LWP 15898)]
[2021:12:06:19:10:16]: Warning: Couldn't expose some properties for card: /dev/dri/card0
[2021:12:06:19:10:16]: Debug: Monitor description
[2021:12:06:19:10:16]: Debug: Resolution: 0x0
[2021:12:06:19:10:16]: Debug: Offset: 0x0
[2021:12:06:19:10:16]: Debug: Desktop resolution: 0x0
[2021:12:06:19:10:16]: Info: Detecting connected monitors
[New Thread 0x7fffee013640 (LWP 15899)]
[2021:12:06:19:10:16]: Info: //////////////////////////////////////////////////////////////////
[2021:12:06:19:10:16]: Info: //                                                              //
[2021:12:06:19:10:16]: Info: //   Testing for available encoders, this may generate errors.  //
[2021:12:06:19:10:16]: Info: //   You can safely ignore those errors.                        //
[2021:12:06:19:10:16]: Info: //                                                              //
[2021:12:06:19:10:16]: Info: //////////////////////////////////////////////////////////////////
[2021:12:06:19:10:16]: Info: Trying encoder [nvenc]
[2021:12:06:19:10:16]: Info: Screencasting with X11
[2021:12:06:19:10:16]: Info: Color coding [Rec. 601]
[2021:12:06:19:10:16]: Info: Color range: [JPEG]
[2021:12:06:19:10:16]: Error: Failed to create a CUDA device: Unknown error occurred
[2021:12:06:19:10:16]: Info: Screencasting with X11
[2021:12:06:19:10:16]: Info: Color coding [Rec. 601]
[2021:12:06:19:10:16]: Info: Color range: [JPEG]
[2021:12:06:19:10:16]: Error: Failed to create a CUDA device: Unknown error occurred
[2021:12:06:19:10:16]: Info: Screencasting with X11
[2021:12:06:19:10:16]: Info: Color coding [Rec. 601]
[2021:12:06:19:10:16]: Info: Color range: [JPEG]
[2021:12:06:19:10:16]: Error: Failed to create a CUDA device: Unknown error occurred
[2021:12:06:19:10:16]: Info: Screencasting with X11
[2021:12:06:19:10:16]: Info: Color coding [Rec. 601]
[2021:12:06:19:10:16]: Info: Color range: [JPEG]
[2021:12:06:19:10:16]: Error: Failed to create a CUDA device: Unknown error occurred
[2021:12:06:19:10:16]: Info: Encoder [nvenc] failed
[2021:12:06:19:10:16]: Info: Trying encoder [vaapi]
[2021:12:06:19:10:16]: Info: Screencasting with X11
[New Thread 0x7fffed37d640 (LWP 15905)]
[New Thread 0x7fffeca3b640 (LWP 15906)]
[New Thread 0x7fffe0d39640 (LWP 15907)]
[New Thread 0x7fffdbfff640 (LWP 15908)]
[New Thread 0x7fffdb7fe640 (LWP 15909)]
[New Thread 0x7fffdaffd640 (LWP 15910)]
[New Thread 0x7fffda7fc640 (LWP 15911)]
[2021:12:06:19:10:16]: Debug: EGL: [Mesa Project]: version [1.5]
[2021:12:06:19:10:16]: Debug: API's supported: [OpenGL OpenGL_ES ]
[New Thread 0x7fffd9ffb640 (LWP 15912)]
[2021:12:06:19:10:16]: Debug: GL: vendor: AMD
[2021:12:06:19:10:16]: Debug: GL: renderer: AMD NAVI12 (DRM 3.41.0, 5.13.0-1005-aws, LLVM 12.0.1)
[2021:12:06:19:10:16]: Debug: GL: version: 4.6 (Compatibility Profile) Mesa 21.2.2
[2021:12:06:19:10:16]: Debug: GL: shader: 4.60
[2021:12:06:19:10:16]: Info: Color coding [Rec. 601]
libva info: VA-API version 1.12.0
[2021:12:06:19:10:16]: Info: Color range: [JPEG]
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_1_12
[New Thread 0x7fffd8ab1640 (LWP 15913)]
[New Thread 0x7fffb7fff640 (LWP 15914)]
[New Thread 0x7fffb77fe640 (LWP 15915)]
[New Thread 0x7fffb6ffd640 (LWP 15916)]
[New Thread 0x7fffb67fc640 (LWP 15917)]
[New Thread 0x7fffb5ffb640 (LWP 15918)]
[New Thread 0x7fffb57fa640 (LWP 15919)]
libva info: va_openDriver() returns 0
[2021:12:06:19:10:16]: Debug: vaapi vendor: Mesa Gallium driver 21.2.2 for AMD NAVI12 (DRM 3.41.0, 5.13.0-1005-aws, LLVM 12.0.1)
mesa: for the --simplifycfg-sink-common option: may only occur zero or one times!
mesa: for the --global-isel-abort option: may only occur zero or one times!
mesa: for the --amdgpu-atomic-optimizations option: may only occur zero or one times!
[Thread 0x7fffd9ffb640 (LWP 15912) exited]
[Thread 0x7fffda7fc640 (LWP 15911) exited]
[Thread 0x7fffdaffd640 (LWP 15910) exited]
[Thread 0x7fffdb7fe640 (LWP 15909) exited]
[Thread 0x7fffdbfff640 (LWP 15908) exited]
[Thread 0x7fffe0d39640 (LWP 15907) exited]
[Thread 0x7fffeca3b640 (LWP 15906) exited]
[Thread 0x7fffed37d640 (LWP 15905) exited]
[2021:12:06:19:10:16]: Info: Screencasting with X11
[New Thread 0x7fffed37d640 (LWP 15920)]
[New Thread 0x7fffeca3b640 (LWP 15921)]
[New Thread 0x7fffda7fc640 (LWP 15922)]
[New Thread 0x7fffdaffd640 (LWP 15923)]
[New Thread 0x7fffe0d39640 (LWP 15924)]
[New Thread 0x7fffdbfff640 (LWP 15925)]
[2021:12:06:19:10:16]: Debug: EGL: [Mesa Project]: version [1.5]
[2021:12:06:19:10:16]: Debug: API's supported: [OpenGL OpenGL_ES ]
[New Thread 0x7fffdb7fe640 (LWP 15926)]
[2021:12:06:19:10:16]: Debug: GL: vendor: AMD
[2021:12:06:19:10:16]: Debug: GL: renderer: AMD NAVI12 (DRM 3.41.0, 5.13.0-1005-aws, LLVM 12.0.1)
[2021:12:06:19:10:16]: Debug: GL: version: 4.6 (Compatibility Profile) Mesa 21.2.2
[2021:12:06:19:10:16]: Debug: GL: shader: 4.60
[2021:12:06:19:10:16]: Info: Color coding [Rec. 601]
[2021:12:06:19:10:16]: Info: Color range: [JPEG]
libva info: VA-API version 1.12.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_1_12
libva info: va_openDriver() returns 0
[2021:12:06:19:10:16]: Debug: vaapi vendor: Mesa Gallium driver 21.2.2 for AMD NAVI12 (DRM 3.41.0, 5.13.0-1005-aws, LLVM 12.0.1)
[Thread 0x7fffdb7fe640 (LWP 15926) exited]
[Thread 0x7fffdbfff640 (LWP 15925) exited]
[Thread 0x7fffe0d39640 (LWP 15924) exited]
[Thread 0x7fffdaffd640 (LWP 15923) exited]
[Thread 0x7fffda7fc640 (LWP 15922) exited]
[Thread 0x7fffeca3b640 (LWP 15921) exited]
[Thread 0x7fffed37d640 (LWP 15920) exited]

Thread 1 "sunshine" received signal SIGSEGV, Segmentation fault.
0x00007fffe6f08c90 in ?? ()
[?2004h[?2004l
[?2004h(gdb) bt
[?2004l
#0  0x00007fffe6f08c90 in  ()
#1  0x00007fffd8c118e9 in  () at /usr/lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so
#2  0x00007ffff228f861 in vaDestroyBuffer () at /lib/x86_64-linux-gnu/libva.so.2
#3  0x00007ffff72d6324 in  () at /lib/x86_64-linux-gnu/libavcodec.so.58
#4  0x00007ffff68bbb67 in av_buffer_pool_uninit () at /lib/x86_64-linux-gnu/libavutil.so.56
#5  0x00007ffff6c31fb4 in  () at /lib/x86_64-linux-gnu/libavcodec.so.58
#6  0x00007ffff6bdfebb in avcodec_close () at /lib/x86_64-linux-gnu/libavcodec.so.58
#7  0x00007ffff716c94d in avcodec_free_context () at /lib/x86_64-linux-gnu/libavcodec.so.58
#8  0x0000555555f3185b in video::free_ctx(AVCodecContext*) (ctx=0x555556b600c0) at /home/ubuntu/sunshine/sunshine/video.cpp:35
#9  0x0000555555f4dc82 in util::Destroy<AVCodecContext*, void, &video::free_ctx>::operator()(AVCodecContext*) (this=0x7fffffffdc78, p=0x555556b600c0) at /home/ubuntu/sunshine/sunshine/utility.h:793
#10 0x0000555555f47260 in util::uniq_ptr<AVCodecContext, util::Destroy<AVCodecContext*, void, &video::free_ctx> >::reset(AVCodecContext*) (this=0x7fffffffdc70, p=0x0)
    at /home/ubuntu/sunshine/sunshine/utility.h:497
#11 0x0000555555f40c1f in util::uniq_ptr<AVCodecContext, util::Destroy<AVCodecContext*, void, &video::free_ctx> >::~uniq_ptr() (this=0x7fffffffdc70, __in_chrg=<optimized out>)
    at /home/ubuntu/sunshine/sunshine/utility.h:492
#12 0x0000555555f40222 in video::session_t::~session_t() (this=0x7fffffffdc70, __in_chrg=<optimized out>) at /home/ubuntu/sunshine/sunshine/video.cpp:324
#13 0x0000555555f50469 in std::_Optional_payload_base<video::session_t>::_M_destroy() (this=0x7fffffffdc70) at /usr/include/c++/10/optional:259
#14 0x0000555555f49b1b in std::_Optional_payload_base<video::session_t>::_M_reset() (this=0x7fffffffdc70) at /usr/include/c++/10/optional:279
#15 0x0000555555f43090 in std::_Optional_payload<video::session_t, false, false, false>::~_Optional_payload() (this=0x7fffffffdc70, __in_chrg=<optimized out>) at /usr/include/c++/10/optional:400
#16 0x0000555555f40038 in std::_Optional_base<video::session_t, false, false>::~_Optional_base() (this=0x7fffffffdc70, __in_chrg=<optimized out>) at /usr/include/c++/10/optional:473
#17 0x0000555555f40058 in std::optional<video::session_t>::~optional() (this=0x7fffffffdc70, __in_chrg=<optimized out>) at /usr/include/c++/10/optional:658
#18 0x0000555555f3795c in video::validate_config(std::shared_ptr<platf::display_t>&, video::encoder_t const&, video::config_t const&) (disp=
    std::shared_ptr<platf::display_t> (use count 1, weak count 0) = {...}, encoder=..., config=...) at /home/ubuntu/sunshine/sunshine/video.cpp:1408
#19 0x0000555555f37ebb in video::validate_encoder(video::encoder_t&) (encoder=...) at /home/ubuntu/sunshine/sunshine/video.cpp:1475
#20 0x0000555555f3983b in video::init() () at /home/ubuntu/sunshine/sunshine/video.cpp:1589
#21 0x0000555555dca573 in main(int, char**) (argc=2, argv=0x7fffffffe308) at /home/ubuntu/sunshine/sunshine/main.cpp:251
[?2004h(gdb) q
[?2004l
[?2004hA debugging session is active.

    Inferior 1 [process 15890] will be killed.

Quit anyway? (y or n) y
[?2004l

In order to test, I tried to comment out the only line of the function marked at the stacktrace, resulting in getting sunshine to run (probably with a terrible solution I did, as I still need to understand what is happening:

void free_ctx(AVCodecContext *ctx) {
  avcodec_free_context(&ctx);
}

System:

hadicharara commented 2 years ago

I've got the same issue on KDE Neon with AMD RX 6700 XT.

schmoelder commented 2 years ago

Same issue on Ubuntu with AMD RX 6600

bscubed commented 2 years ago

Same issue on Arch, also with an AMD RX 6600. Any workarounds so far?

hadicharara commented 2 years ago

The maintainer seems to have disappeared. We need to fork it.

sergioperez commented 2 years ago

Same issue on Arch, also with an AMD RX 6600. Any workarounds so far?

Making this change in sunshine/video.cpp will make it start working for you. It is just a temporary workaround though :)

void free_ctx(AVCodecContext *ctx) {
  avcodec_free_context(&ctx);
}
void free_ctx(AVCodecContext *ctx) {
  //avcodec_free_context(&ctx);
}
ReenigneArcher commented 2 years ago

The maintainer seems to have disappeared. We need to fork it.

See here: https://github.com/SunshineStream/Sunshine

@sergioperez feel free to make an issue on this other repo.