hrydgard / ppsspp

A PSP emulator for Android, Windows, Mac and Linux, written in C++. Want to contribute? Join us on Discord at https://discord.gg/5NJB6dD or just send pull requests / issues. For discussion use the forums at forums.ppsspp.org.
https://www.ppsspp.org
Other
11.17k stars 2.17k forks source link

Libretro build crashing or freezing on thread pause #13430

Closed i30817 closed 4 years ago

i30817 commented 4 years ago

Description

Self built retroarch from upstream; with make (not cmake which doesn't work right now). It crashes whenever you try to save, reset or close the core (and probably other things). Using gdb with a build with DEBUG=1 and ctrl+c during the 'pause' it shows it's at a mutex wait on the emulation thread pause.

Expected behavior

Not crash or freeze I guess.

Actual behavior

Freezes and crashes.

here is a freeze on savestate:

Thread 1 "retroarch" received signal SIGINT, Interrupt.
futex_wait_cancelable (private=<optimized out>, expected=0, 
    futex_word=0x555557703a1c) at ../sysdeps/nptl/futex-internal.h:183
183 ../sysdeps/nptl/futex-internal.h: No such file or directory.
(gdb) bt
#0  futex_wait_cancelable
    (private=<optimized out>, expected=0, futex_word=0x555557703a1c)
    at ../sysdeps/nptl/futex-internal.h:183
#1  __pthread_cond_wait_common
    (abstime=0x0, clockid=0, mutex=0x5555577039c8, cond=0x5555577039f0)
    at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x5555577039f0, mutex=0x5555577039c8)
    at pthread_cond_wait.c:638
#3  0x00007ffff5f96e20 in std::condition_variable::wait(std::unique_lock<std::mutex>&) () at /lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007fffe7194feb in GLRenderManager::ThreadFrame() (this=0x555557703970)
    at ../ext/native/thin3d/GLRenderManager.cpp:199
#5  0x00007fffe7578192 in LibretroGLContext::ThreadFrame()
    (this=0x5555563d4600) at ../libretro/LibretroGLContext.h:30
#6  0x00007fffe756e383 in Libretro::EmuThreadPause() ()
    at ../libretro/libretro.cpp:512
#7  0x00007fffe756f5b9 in retro_serialize_size() ()
    at ../libretro/libretro.cpp:794
#8  0x000055555560bb60 in core_serialize_size (info=0x7fffffff6310)
    at retroarch.c:40495
#9  0x00005555555d4876 in command_event_main_state
    (p_rarch=0x5555562c78a0 <rarch_st>, cmd=11) at retroarch.c:15399
#10 0x00005555555d574f in command_event (cmd=CMD_EVENT_SAVE_STATE, data=0x0)
    at retroarch.c:15907
#11 0x00005555558882f9 in generic_action_ok_command (cmd=CMD_EVENT_SAVE_STATE)
    at menu/cbs/menu_cbs_ok.c:1619
#12 0x000055555588ddf8 in action_ok_save_state
    (path=0x7fffffffce98 "Save State", label=0x7fffffffcf97 "savestate", type=155, idx=5, entry_idx=0) at menu/cbs/menu_cbs_ok.c:3957
#13 0x00005555555bebf4 in generic_menu_entry_action
    (userdata=0x55555658e240, entry=0x7fffffffce80, i=5, action=MENU_ACTION_OK)
    at retroarch.c:4780
#14 0x00005555558233a6 in xmb_menu_entry_action
    (userdata=0x55555658e240, entry=0x7fffffffce80, i=5, action=MENU_ACTION_OK)
--Type <RET> for more, q to quit, c to continue without paging--
    at menu/drivers/xmb.c:3805
#15 0x00005555555bfba1 in menu_entry_action
    (entry=0x7fffffffce80, i=5, action=MENU_ACTION_OK) at retroarch.c:5156
#16 0x00005555555be7f4 in generic_menu_iterate
    (p_rarch=0x5555562c78a0 <rarch_st>, data=0x5555565841f0, userdata=0x55555658e240, action=MENU_ACTION_OK, current_time=102935147916) at retroarch.c:4705
#17 0x00005555555c2ba9 in menu_driver_iterate
    (iterate=0x7fffffffda40, current_time=102935147916) at retroarch.c:6759
#18 0x0000555555608958 in runloop_check_state
    (p_rarch=0x5555562c78a0 <rarch_st>, settings=0x7fffedc49010, current_time=102935147916) at retroarch.c:39221
#19 0x000055555560a394 in runloop_iterate () at retroarch.c:39805
#20 0x00005555555d88ee in rarch_main (argc=1, argv=0x7fffffffde48, data=0x0)
    at retroarch.c:17556
#21 0x00005555555d8954 in main (argc=1, argv=0x7fffffffde48)
    at retroarch.c:17633

here is a crash on restart core - it's not useful, except for the name of the stopped thread. I had to restart twice for this to happen in the debug build.

(gdb) r
Starting program: /media/i30817/Huginn/Documents/projects/RetroArch/retroarch 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffedc48700 (LWP 144942)]
[New Thread 0x7fffed447700 (LWP 144943)]
[New Thread 0x7fffe22ed700 (LWP 144944)]
[New Thread 0x7fffe1aec700 (LWP 144945)]
[New Thread 0x7fffe12eb700 (LWP 144946)]
[New Thread 0x7fffe0aea700 (LWP 144947)]
[New Thread 0x7fffd3fff700 (LWP 144948)]
[New Thread 0x7fffd37fe700 (LWP 144949)]
[Thread 0x7fffd3fff700 (LWP 144948) exited]
[Thread 0x7fffe0aea700 (LWP 144947) exited]
[Thread 0x7fffe12eb700 (LWP 144946) exited]
[Thread 0x7fffe1aec700 (LWP 144945) exited]
[Thread 0x7fffe22ed700 (LWP 144944) exited]
[New Thread 0x7fffedc48700 (LWP 144950)]
[Thread 0x7fffd37fe700 (LWP 144949) exited]
[Thread 0x7fffed447700 (LWP 144943) exited]
[Thread 0x7fffedc48700 (LWP 144942) exited]
[New Thread 0x7fffd37fe700 (LWP 144951)]
[New Thread 0x7fffed447700 (LWP 144952)]
[New Thread 0x7fffe22ed700 (LWP 144953)]
[New Thread 0x7fffe08eb700 (LWP 144954)]
[New Thread 0x7fffd3fff700 (LWP 144955)]
[New Thread 0x7fffd097f700 (LWP 144956)]
[New Thread 0x7fffcbfff700 (LWP 144957)]
[New Thread 0x7fffcaffd700 (LWP 144958)]
[Thread 0x7fffd37fe700 (LWP 144951) exited]
[New Thread 0x7fffc92a2700 (LWP 144959)]
[Thread 0x7fffcbfff700 (LWP 144957) exited]
[New Thread 0x7fffcbfff700 (LWP 144960)]
[New Thread 0x7fffd37fe700 (LWP 144961)]
[Thread 0x7fffcbfff700 (LWP 144960) exited]
[Thread 0x7fffd37fe700 (LWP 144961) exited]
[New Thread 0x7fffd37fe700 (LWP 144962)]
[New Thread 0x7fffcbfff700 (LWP 144963)]
[Thread 0x7fffd37fe700 (LWP 144962) exited]
--Type <RET> for more, q to quit, c to continue without paging--

Thread 19 "Emu" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffc92a2700 (LWP 144959)]
0x00007fffe0b0d029 in ?? ()
(gdb) bt
#0  0x00007fffe0b0d029 in  ()
#1  0x00007fffc92a1640 in  ()
#2  0x00007fffc92a1640 in  ()
#3  0x00007fffffffda70 in  ()
#4  0x00007fffffffda6f in  ()
#5  0x00007fffffffda6e in  ()
#6  0x00007fffc92a1430 in  ()
#7  0x0000000000000000 in  ()

Steps to reproduce the bug

Just load any game on the core and try to savestate from the menu (freeze), or reset (crash), or close the core (freeze).

Bisect Results

No clue, the core only recently started to work again for me when @twinaphex committed upstream a glew replacement fix (that i first i thought was doing nothing because i was trying to use cmake instead of make to build).

Version/Commit

Environment information

running on wayland with Retroarch build just for wayland/kms and without xwayland/x11 support (to not use xwayland and make the cores and menu slower).

i30817 commented 4 years ago

Threaded video setting in retroarch does not influence these. Or at least not completely, i was able to savestate once, but subsequent tries froze again.

i30817 commented 4 years ago

This might be a Retroarch problem, i'm bisecting retroarch after noticing that even going back 1-2 years in ppsspp didn't change things.

Edit: no it isn't. It's https://github.com/hrydgard/ppsspp/issues/11429 but the hack stopped working for some reason. No wonder the break of the hangs sent me to the mutex that the 'bandaid' commit for that issue introduced.