flyinghead / flycast

Flycast is a multiplatform Sega Dreamcast, Naomi, Naomi 2 and Atomiswave emulator
GNU General Public License v2.0
1.38k stars 168 forks source link

Flycast segfaults when launched directly from TTY using KMSDRM #1220

Closed vanfanel closed 11 months ago

vanfanel commented 11 months ago

Please Note: This form is the minimum required information for submitting bugs.
Removing this form may lead to your issue being closed until it is completed.

Platform / OS / Hardware: GNU/Linux x86_64 or aarch64

Github hash: cb91ad3ae0c1291485892bf3a9663a2fd303ce83

Hardware: Any hardware from modern i5 1235U to Raspberry Pi 4. The same issue happens all hardware where I have tried.

Description of the Issue

Flycast core segfaults when launched from the command line on KMS/DRM like this: retroarch -L .config/retroarch/cores/flycast_libretro.so dreamcast/Soulcalibur.chd

Using full absolute path, same problem happens: retroarch -L /root/.config/retroarch/cores/flycast_libretro.so /root/dreamcast/Soulcalibur.chd

(Works fine when launched from the command line on Wayland, and also works fine on the TTY if launched using the exact same command on an SSH session).

Logs Gathered


[INFO] [Config]: Looking for config in: "/root/.config/retroarch/retroarch.cfg".
[INFO] === Build =======================================
[INFO] CPU Model Name: 12th Gen Intel(R) Core(TM) i5-1235U
[INFO] Capabilities: MMX MMXEXT SSE SSE2 SSE3 SSSE3 SSE4 SSE42 AES AVX AVX2 
[INFO] Version: 1.16.0
[INFO] Built: Oct  1 2023
[INFO] =================================================
[INFO] [Input]: Found input driver: "udev".
[INFO] [Core]: Loading dynamic libretro core from: ".config/retroarch/cores/flycast_libretro.so"
[INFO] [Environ]: GET_CORE_OPTIONS_VERSION.
[INFO] [Environ]: RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL.
[INFO] [Environ]: SET_CONTROLLER_INFO.
[INFO] [Overrides]: Redirecting save file to "/root/.config/retroarch/saves/Soulcalibur (USA).srm".
[INFO] [Overrides]: Redirecting save state to "/root/.config/retroarch/states/Soulcalibur (USA).state".
[INFO] [Environ]: GET_LOG_INTERFACE.
[libretro INFO] shell/libretro/libretro.cpp:322 N[BOOT]: retro_init
[INFO] [Environ]: GET_PERF_INTERFACE.
[INFO] [Environ]: SET_PIXEL_FORMAT: XRGB8888.
[INFO] [Environ]: SET_KEYBOARD_CALLBACK.
[INFO] [Environ]: GET_DISK_CONTROL_INTERFACE_VERSION.
[INFO] [Environ]: SET_DISK_CONTROL_EXT_INTERFACE.
[libretro INFO] core/hw/mem/addrspace.cpp:431 N[VMEM]: Info: nvmem is enabled
[libretro INFO] core/hw/mem/addrspace.cpp:462 N[VMEM]: BASE 0x7f7f5e9b0000 RAM(16 MB) 0x7f7f6a9b0000 VRAM64(8 MB) 0x7f7f629b0000 ARAM(2 MB) 0x7f7f7e9b0000
[INFO] [Content]: Content loading skipped. Implementation will load it on its own.
[libretro INFO] shell/libretro/libretro.cpp:1921 N[BOOT]: retro_load_game: Soulcalibur (USA).chd
[INFO] [Environ]: GET_RUMBLE_INTERFACE.
[INFO] [Environ]: SYSTEM_DIRECTORY: "/root/.config/retroarch/system".
[INFO] [Environ]: GET_SAVE_DIRECTORY.
[ERROR] [Environ]: GET_VARIABLE: pvr.rend - Invalid value.
[ERROR] [Environ]: GET_VARIABLE: rend.PerStripSorting - Invalid value.
[INFO] [Environ]: SET_SAVE_STATE_IN_BACKGROUND: yes.
[libretro INFO] File extension is: .chd
[INFO] [Environ]: GET_PREFERRED_HW_RENDER, video driver name: vulkan.
[INFO] [Environ]: GET_PREFERRED_HW_RENDER - Context callback set to RETRO_HW_CONTEXT_VULKAN.
[INFO] [Environ]: Driver switching disabled, GET_PREFERRED_HW_RENDER will be ignored.
[INFO] [Environ]: SET_HW_RENDER, context type: vulkan.
[INFO] Requesting Vulkan context.
[INFO] [Environ]: SET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE.
[libretro INFO] core/hw/mem/addrspace.cpp:431 N[VMEM]: Info: nvmem is enabled
[libretro INFO] core/hw/mem/addrspace.cpp:462 N[VMEM]: BASE 0x7f7f5e9b0000 RAM(16 MB) 0x7f7f6a9b0000 VRAM64(8 MB) 0x7f7f629b0000 ARAM(2 MB) 0x7f7f7e9b0000
[ERROR] [Environ]: GET_VARIABLE: pvr.rend - Invalid value.
[ERROR] [Environ]: GET_VARIABLE: rend.PerStripSorting - Invalid value.
[libretro INFO] core/emulator.cpp:54 N[BOOT]: Game ID is [T1401N]
[libretro INFO] core/emulator.cpp:595 N[BOOT]: Did not load BIOS, using reios
[libretro INFO] core/emulator.cpp:54 N[BOOT]: Game ID is [T1401N]
[INFO] [Environ]: SET_ROTATION: 0
[INFO] [Environ]: SET_INPUT_DESCRIPTORS:
[INFO] [Replay]: Found last replay slot: #0
[INFO] [SRAM]: Skipping SRAM load.
[INFO] [Core]: Version of libretro API: 1, Compiled against API: 1
[libretro INFO] shell/libretro/libretro.cpp:2270 N[RENDERER]: retro_get_system_av_info: Res=480
[INFO] [Core]: Geometry: 640x480, Aspect: 1.333, FPS: 60.00, Sample rate: 44100.00 Hz.
[INFO] [Audio]: Set audio input rate to: 44101.76 Hz.
[INFO] [Video]: Set video size to: 1920x1080.
[INFO] [Video]: Using HW render, vulkan driver forced.
[ERROR] [Wayland]: Failed to connect to Wayland server.
[INFO] [Vulkan]: Vulkan dynamic library loaded.
[INFO] [Vulkan]: Found vulkan context: "khr_display".
[INFO] [Vulkan]: Detecting screen resolution: 0x0.
[INFO] [Vulkan]: Found GPU at index 0: "Intel(R) Graphics (ADL GT2)".
[INFO] [Vulkan]: Using GPU index 0.
[INFO] [Vulkan]: Got HW context negotiation interface 1.
[INFO] [Vulkan]: Found GPU at index 0: "Intel(R) Graphics (ADL GT2)".
[INFO] [Vulkan]: Using GPU index 0.
[INFO] [Vulkan]: Using semaphores for WSI acquire.
[INFO] [Vulkan]: Using GPU: "Intel(R) Graphics (ADL GT2)".
[INFO] [Vulkan]: Got 2 swapchain images.
[INFO] [Vulkan]: Using resolution 1920x1080.
[INFO] [Vulkan]: Using BGRA8888 format.
[INFO] [Shaders]: Specific shader preset found at "/root/.config/retroarch/config/global.slangp".
[INFO] [slang]: Compiling shader: "/root/.config/retroarch/shaders/slang/crt/shaders/fakelottes.slang".
[INFO] [Video]: Graphics driver did not initialize an input driver. Attempting to pick a suitable driver.
[WARN] [udev]: Full-screen pointer won't be available.
[INFO] [udev]: Keyboard #0: "Power Button" (/dev/input/event2).
[INFO] [udev]: Keyboard #1: "Video Bus" (/dev/input/event7).
[INFO] [udev]: Keyboard #2: "Power Button" (/dev/input/event1).
[INFO] [udev]: Keyboard #3: "Sleep Button" (/dev/input/event0).
[INFO] [udev]: Keyboard #4: "Logitech Wireless Keyboard PID:4023" (/dev/input/event3).
[INFO] [udev]: Mouse/Touch #0: "Logitech Wireless Mouse PID:4022" (REL) /dev/input/event4.
[INFO] [udev]: Pad #0 (/dev/input/event6) supports force feedback.
[INFO] [udev]: Pad #0 (/dev/input/event6) supports 16 force feedback effects.
[INFO] [Autoconf]: Microsoft X-Box 360 pad (1118/654) not configured.
[INFO] [Joypad]: Found joypad driver: "udev".
[INFO] [Video]: Found display server: "null".
[WARN] [udev]: Mouse grab/ungrab feature unavailable.
[libretro INFO] shell/libretro/libretro.cpp:1733 N[RENDERER]: retro_vk_context_reset
[libretro INFO] core/rend/vulkan/vk_context_lr.cpp:195 N[RENDERER]: GPU Supports Vulkan API: 1.3.255
[libretro INFO] core/rend/vulkan/vk_context_lr.cpp:201 N[RENDERER]: GPU Supports vkGetPhysicalDeviceProperties2
[libretro INFO] core/rend/vulkan/vulkan_context.h:264 N[RENDERER]: Using depth format D32SfloatS8Uint tiling Optimal
[libretro INFO] core/rend/vulkan/vulkan_renderer.cpp:30 N[RENDERER]: VulkanRenderer::Init
[INFO] [ALSA] Using ALSA version 1.2.8
[INFO] [ALSA]: Using S16_LE sample format for PLAYBACK device "default"
[INFO] [ALSA]: Period: 5 periods per buffer (397 frames, 1588 bytes)
[INFO] [ALSA]: Buffer size: 1985 frames (7940 bytes)
[INFO] [ALSA]: Can pause: yes.
[INFO] [ALSA]: Initialized PLAYBACK device "default"
[INFO] [Audio]: Started synchronous audio driver.
[ERROR] [Microphone]: Failed to start microphone driver. Will continue without audio input.
[INFO] [Display]: Found display driver: "vulkan".
[INFO] [Playlist]: Loading history file: "/root/.config/retroarch/content_history.lpl".
[INFO] [Playlist]: Loading history file: "/root/.config/retroarch/content_music_history.lpl".
[INFO] [Playlist]: Loading favorites file: "/root/.config/retroarch/content_favorites.lpl".
[INFO] [Environ]: SET_INPUT_DESCRIPTORS:
flyinghead commented 11 months ago

There doesn't seem to be anything interesting in this log. Flycast correctly initializes its vulkan renderer.

Can you get a stacktrace? What makes you think flycast is at fault here?

vanfanel commented 11 months ago

@flyinghead I can get a GDB backtrace (is it the same as an stacktrace? I believe so), here it is:

Thread 9 "retroarch_debug" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fdd1d6b56c0 (LWP 9118)]
bm_GetCode (addr=2684354560) at /root/src/libretro/flycast/core/hw/sh4/dyna/blockmanager.cpp:49
49              DynarecCodeEntryPtr rv = FPCA(addr);
(gdb) bt
#0  bm_GetCode (addr=2684354560) at /root/src/libretro/flycast/core/hw/sh4/dyna/blockmanager.cpp:49
#1  0x00007fdd5952ba66 in bm_GetCodeByVAddr (addr=2684354560)
    at /root/src/libretro/flycast/core/hw/sh4/dyna/blockmanager.cpp:59
#2  0x00007fdd59543036 in SH4_TCB () at /root/src/libretro/flycast/core/hw/sh4/modules/mmu.h:112
#3  0xb7566d8b95e56dfa in ?? ()
#4  0x00007fdd1ceb5000 in ?? ()
#5  0x00007fff7bfd42e0 in ?? ()
#6  0x0000562a0f854fe0 in ?? ()
#7  0x00007fdd1d6b4cd7 in ?? ()
#8  0x00007fdd1d6b4880 in ?? ()
#9  0x00007fdd5afe5860 in ?? () from /root/.config/retroarch/cores/flycast_libretro_debug.so
#10 0x00007fdd5a1e2398 in X64Dynarec::mainloop (this=0x7fdd5c88b860 <instance>)
    at /root/src/libretro/flycast/core/rec-x64/rec_x64.cpp:1339
#11 0x00007fdd5a043288 in recSh4_Run () at /root/src/libretro/flycast/core/hw/sh4/dyna/driver.cpp:112
#12 0x00007fdd58f61260 in Emulator::runInternal (this=0x7fdd5afe5860 <emu>)
    at /root/src/libretro/flycast/core/emulator.cpp:691
#13 0x00007fdd58f61e92 in operator() (__closure=0x562a0f855018)
    at /root/src/libretro/flycast/core/emulator.cpp:947
#14 0x00007fdd58f64354 in std::__invoke_impl<void, Emulator::start()::<lambda()> >(std::__invoke_other, struct {...} &&) (__f=...) at /usr/include/c++/12/bits/invoke.h:61                                                    
#15 0x00007fdd58f64317 in std::__invoke<Emulator::start()::<lambda()> >(struct {...} &&) (__fn=...)
    at /usr/include/c++/12/bits/invoke.h:96
#16 0x00007fdd58f642c4 in std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >::_M_invoke<0>(std::_Index_tuple<0>) (this=0x562a0f855018) at /usr/include/c++/12/bits/std_thread.h:252                           
#17 0x00007fdd58f64298 in std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >::operator()(void)
--Type <RET> for more, q to quit, c to continue without paging--
    (this=0x562a0f855018) at /usr/include/c++/12/bits/std_thread.h:259
#18 0x00007fdd58f6413d in std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void>::operator()(void) const (this=0x7fdd1d6b4d60) at /usr/include/c++/12/future:1410                        
#19 0x00007fdd58f64064 in std::__invoke_impl<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void>&>(std::__invoke_other, std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void> &) (__f=...) at /usr/include/c++/12/bits/invoke.h:61                                            
#20 0x00007fdd58f63ec4 in std::__invoke_r<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter>, std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void>&>(std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void> &) (      
    __fn=...) at /usr/include/c++/12/bits/invoke.h:116
#21 0x00007fdd58f63d4f in std::_Function_handler<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter>(), std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void> >::_M_invoke(const std::_Any_data &) (__functor=...)                                           
    at /usr/include/c++/12/bits/std_function.h:291
#22 0x00007fdd58f66cc3 in std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>::operator()() const (this=0x7fdd1d6b4d60)                                           
    at /usr/include/c++/12/bits/std_function.h:591
#23 0x00007fdd58f65adb in std::__future_base::_State_baseV2::_M_do_set(std::function<std::unique_ptr<std::__fut--Type <RET> for more, q to quit, c to continue without paging--                                               
ure_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*) (this=0x562a0f854fe0,         
    __f=0x7fdd1d6b4d60, __did_set=0x7fdd1d6b4cd7) at /usr/include/c++/12/future:572
#24 0x00007fdd58f6e085 in std::__invoke_impl<void, void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::__invoke_memfun_deref, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&) (                                           
    __f=@0x7fdd1d6b4cf0: (void (std::__future_base::_State_baseV2::*)(std::__future_base::_State_baseV2 * const, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter>()> *, bool *)) 0x7fdd58f65ab4 <std::__future_base::_State_baseV2::_M_do_set(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*)>, 
    __t=@0x7fdd1d6b4ce8: 0x562a0f854fe0) at /usr/include/c++/12/bits/invoke.h:74
#25 0x00007fdd58f6a9dd in std::__invoke<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&) (                                                                                  
    __fn=@0x7fdd1d6b4cf0: (void (std::__future_base::_State_baseV2::*)(std::__future_base::_State_baseV2 * const, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter>()> *, bool *)) 0x7fdd58f65ab4 <std::__future_base::_State_baseV2::_M_do_set(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*)>)
--Type <RET> for more, q to quit, c to continue without paging--
    at /usr/include/c++/12/bits/invoke.h:96
#26 0x00007fdd58f66aaa in std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&)::{lambda()#1}::operator()() const (__closure=0x7fdd1d6b4c60)     
    at /usr/include/c++/12/mutex:852
#27 0x00007fdd58f6aa11 in std::once_flag::_Prepare_execution::_Prepare_execution<std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&)::{lambda()#1}>(void (std::__future_base::_State_baseV2::*&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*))::{lambda()#1}::operator()() const (__closure=0x0) 
    at /usr/include/c++/12/mutex:788
#28 0x00007fdd58f6aa22 in std::once_flag::_Prepare_execution::_Prepare_execution<std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::uniqu--Type <RET> for more, q to quit, c to continue without paging--                                               
e_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&)::{lambda()#1}>(void (std::__future_base::_State_baseV2::*&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*))::{lambda()#1}::_FUN() ()                          
    at /usr/include/c++/12/mutex:788
#29 0x00007fdd5d3cdea7 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#30 0x00007fdd58f5e0f6 in __gthread_once (__once=0x562a0f854ff8, __func=0x7fdd5d6d3200 <__once_proxy>)
    at /usr/include/x86_64-linux-gnu/c++/12/bits/gthr-default.h:700
#31 0x00007fdd58f66b1c in std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&) (__once=...,                                                     
    __f=@0x7fdd1d6b4cf0: (void (std::__future_base::_State_baseV2::*)(std::__future_base::_State_baseV2 * const, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter>()> *, bool *)) 0x7fdd58f65ab4 <std::__future_base::_State_baseV2::_M_do_set(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*)>)
    at /usr/include/c++/12/mutex:859
#32 0x00007fdd58f65905 in std::__future_base::_State_baseV2::_M_set_result(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>, bool) (this=0x562a0f854fe0,       
    __res=..., __ignore_failure=false) at /usr/include/c++/12/future:412
#33 0x00007fdd58f6396b in std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void>::_M_run(void) (this=0x562a0f854fe0) at /usr/include/c++/12/future:1749              
#34 0x00007fdd58f64b2c in std::__invoke_impl<void, void (std::__future_base::_Async_state_impl<std::thread::_In--Type <RET> for more, q to quit, c to continue without paging--                                               
voker<std::tuple<Emulator::start()::<lambda()> > >, void>::*)(), std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void>*>(std::__invoke_memfun_deref, void (std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void>::*&&)(std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void> * const), std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void> *&&) (                                                                                               
    __f=@0x562a0f9974a0: (void (std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void>::*)(std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void> * const)) 0x7fdd58f6390e <std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void>::_M_run(void)>, 
    __t=@0x562a0f997498: 0x562a0f854fe0) at /usr/include/c++/12/bits/invoke.h:74
#35 0x00007fdd58f64a8b in std::__invoke<void (std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void>::*)(), std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void>*>(void (std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void>::*&&)(std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void> * const)) (                             
    __fn=@0x562a0f9974a0: (void (std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void>::*)(std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void> * const)) 0x7fdd58f6390e <std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void>::_M_run(void)>)
    at /usr/include/c++/12/bits/invoke.h:96
#36 0x00007fdd58f649c5 in std::thread::_Invoker<std::tuple<void (std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void>::*)(), std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void>*> >::_M_invoke<0, 1>(std::_Index_tuple<0, 1>) (this=0x562a0f997498) at /usr/include/c++/12/bits/std_thread.h:252                                    
--Type <RET> for more, q to quit, c to continue without paging--
#37 0x00007fdd58f6490a in std::thread::_Invoker<std::tuple<void (std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void>::*)(), std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void>*> >::operator()(void) (              
    this=0x562a0f997498) at /usr/include/c++/12/bits/std_thread.h:259
#38 0x00007fdd58f64506 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void>::*)(), std::__future_base::_Async_state_impl<std::thread::_Invoker<std::tuple<Emulator::start()::<lambda()> > >, void>*> > >::_M_run(void) (this=0x562a0f997490) at /usr/include/c++/12/bits/std_thread.h:210                                     
#39 0x00007fdd5d6d44a3 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#40 0x00007fdd5d3c9044 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#41 0x00007fdd5d44961c in ?? () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) 

I had to build debug versions of both RetroArch and the Flycast core to get this, so I named them retroarch_debug and flycast_libretro_debug.so, respectively.

What makes me believe this is a Flycast issue is that no other cores do this, they all work fine from TTY on KMS/DRM.

flyinghead commented 11 months ago

This is an expected SIGSEGV. Flycast uses them a lot. Try to put a breakpoint at common.cpp:69 and ignore SIGSEGV:

break common.cpp:69
handle SIGSEGV nostop noprint
run
vanfanel commented 11 months ago

@flyinghead After doing what you told me, the program is terminated without any warning, look at this gdb session:

root@DietPi:~# gdb
GNU gdb (Debian 13.1-3) 13.1
Copyright (C) 2023 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".
(gdb) attach 1305
Attaching to process 1305
Reading symbols from /usr/local/bin/retroarch_debug...
Reading symbols from /lib/x86_64-linux-gnu/libasound.so.2...
(No debugging symbols found in /lib/x86_64-linux-gnu/libasound.so.2)
Reading symbols from /usr/local/lib64/libwayland-egl.so.1...
(No debugging symbols found in /usr/local/lib64/libwayland-egl.so.1)
Reading symbols from /usr/local/lib64/libwayland-client.so.0...
(No debugging symbols found in /usr/local/lib64/libwayland-client.so.0)
Reading symbols from /usr/local/lib64/libwayland-cursor.so.0...
(No debugging symbols found in /usr/local/lib64/libwayland-cursor.so.0)
Reading symbols from /lib/x86_64-linux-gnu/libxkbcommon.so.0...
(No debugging symbols found in /lib/x86_64-linux-gnu/libxkbcommon.so.0)
Reading symbols from /lib/x86_64-linux-gnu/libudev.so.1...
(No debugging symbols found in /lib/x86_64-linux-gnu/libudev.so.1)
Reading symbols from /usr/local/lib64/libgbm.so.1...
(No debugging symbols found in /usr/local/lib64/libgbm.so.1)
Reading symbols from /usr/local/lib64/libdrm.so.2...
Reading symbols from /usr/local/lib64/libGLESv2.so.2...
(No debugging symbols found in /usr/local/lib64/libGLESv2.so.2)
Reading symbols from /usr/local/lib64/libEGL.so.1...
(No debugging symbols found in /usr/local/lib64/libEGL.so.1)
Reading symbols from /lib/x86_64-linux-gnu/libstdc++.so.6...
(No debugging symbols found in /lib/x86_64-linux-gnu/libstdc++.so.6)
Reading symbols from /lib/x86_64-linux-gnu/libm.so.6...
(No debugging symbols found in /lib/x86_64-linux-gnu/libm.so.6)
Reading symbols from /lib/x86_64-linux-gnu/libgcc_s.so.1...
(No debugging symbols found in /lib/x86_64-linux-gnu/libgcc_s.so.1)
Reading symbols from /lib/x86_64-linux-gnu/libc.so.6...
(No debugging symbols found in /lib/x86_64-linux-gnu/libc.so.6)
Reading symbols from /lib64/ld-linux-x86-64.so.2...
(No debugging symbols found in /lib64/ld-linux-x86-64.so.2)
Reading symbols from /lib/x86_64-linux-gnu/libffi.so.8...
(No debugging symbols found in /lib/x86_64-linux-gnu/libffi.so.8)
Reading symbols from /usr/local/lib64/libwayland-server.so.0...
(No debugging symbols found in /usr/local/lib64/libwayland-server.so.0)
Reading symbols from /lib/x86_64-linux-gnu/libexpat.so.1...
(No debugging symbols found in /lib/x86_64-linux-gnu/libexpat.so.1)
Reading symbols from /usr/local/lib64/libGLdispatch.so.0...
(No debugging symbols found in /usr/local/lib64/libGLdispatch.so.0)
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007f97ceb1709d in read () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) break common.cpp:69
No source file named common.cpp.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (common.cpp:69) pending.
(gdb) handle SIGSEGV nostop noprint
Signal        Stop      Print   Pass to program Description
SIGSEGV       No        No      Yes             Segmentation fault
(gdb) c
Continuing.
[New Thread 0x7f97ce9256c0 (LWP 1324)]
[New Thread 0x7f97a07ff6c0 (LWP 1325)]
[New Thread 0x7f979fc476c0 (LWP 1326)]
[New Thread 0x7f979ce5b6c0 (LWP 1327)]
[New Thread 0x7f978ffff6c0 (LWP 1328)]
[New Thread 0x7f978f7fe6c0 (LWP 1329)]
[New Thread 0x7f978effd6c0 (LWP 1330)]
[New Thread 0x7f978e7fc6c0 (LWP 1331)]
[Thread 0x7f978e7fc6c0 (LWP 1331) exited]
[Thread 0x7f978effd6c0 (LWP 1330) exited]
[Thread 0x7f978f7fe6c0 (LWP 1329) exited]
[Thread 0x7f978ffff6c0 (LWP 1328) exited]
[Thread 0x7f979fc476c0 (LWP 1326) exited]
[Thread 0x7f97a07ff6c0 (LWP 1325) exited]
[Thread 0x7f97ce9256c0 (LWP 1324) exited]
[Thread 0x7f97cee2a780 (LWP 1305) exited]
[Thread 0x7f979ce5b6c0 (LWP 1327) exited]
[New process 1305]

Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.
(gdb) bt
No stack.

Note that I have to launch RA/Flycast locally and debug over ssh, that's why there's that attach on my GDB session.

flyinghead commented 11 months ago

Yes, this is strange. Also the unexpected SIGSEGV should print out some error (that's what line 69 in common.cpp does). Also I don't see gdb reading flycast_libretro.so symbols. Are you running the debug version of the core?

vanfanel commented 11 months ago

I am sure I am using the debug version of the core: just take into account that it was launched locally, then GDB is attached to it. I have to do it like that because, if I run RetroArch over ssh, the issue does not happen.

This is over ssh:

root@DietPi:~# gdb --args retroarch_debug -L /root/.config/retroarch/cores/flycast_libretro_debug.so /root/Soulcalibur\ \(USA\).chd
GNU gdb (Debian 13.1-3) 13.1
Copyright (C) 2023 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 retroarch_debug...
(gdb) r
Starting program: /usr/local/bin/retroarch_debug -L /root/.config/retroarch/cores/flycast_libretro_debug.so /root/Soulcalibur\ \(USA\).chd
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

...but debuging it like that is not use because the issue won't manifest unless I launch RetroArch locally as I said.

flyinghead commented 11 months ago

We already discussed this problem in the past: https://github.com/flyinghead/flycast/issues/626

It's been reported by other users as well: https://github.com/flyinghead/flycast/issues/578

The conclusion is still the same: This is not a Flycast issue

vanfanel commented 11 months ago

@flyinghead Oh, sorry about that! I somehow recalled we had discussed this already, but couldn't find the issue thread because I wasn't sure. I thank you sincerely for being so patient, seeing that we already went through this in the past.

If it helps, it's the only core where it happens as I said, and also it does NOT happen if RetroArch is launched then the core is loaded from inside RetroArch.

Also should I take this to the RetroArch people again then?

vanfanel commented 11 months ago

@flyinghead I noticed that passing < /dev/null at the end of the command line, the segfault does not happen an the flycast core works fine on the TTY!! Does it give you any clues?

flyinghead commented 11 months ago

the same clue as in #578: this is not a Flycast issue

vanfanel commented 11 months ago

the same clue as in #578: this is not a Flycast issue

Then, is It a RetroArch issue?

theflyingape commented 3 weeks ago

I'd like to add to this thread that while appending < /dev/null does indeed allow retroarch -L flycast to boot from KMS (thank you!!), it does not need any of that when running off a Wayland display - either from a terminal or a RetroArch frontend.

If it helps, I noticed I also had to assign input_auto_game_focus = "0" in its Flycast.cfg to avoid starting up from using Input Auto Focus ON as it will hang miserably using the controller hotkey exit until I press Ctrl/C.

Core was built on Pi5 using: cmake -DLIBRETRO=ON -DUSE_OPENGL=OFF ..