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.38k stars 2.19k forks source link

(libretro) Crashes with opengl (or: missing asset file should print a message before crashing) #12722

Closed orbea closed 4 years ago

orbea commented 4 years ago

What happens?

When starting the ppsspp libretro core with RetroArch and the gl video driver it will immediately crash.

(gdb) r -L lib/ppsspp_libretro.so test.cso 
Starting program: /usr/games/retroarch -L lib/ppsspp_libretro.so test.cso
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
/usr/lib64/../share/gcc-9.2.0/python/libstdcxx/v6/xmethods.py:731: SyntaxWarning: list indices must be integers or slices, not str; perhaps you missed a comma?
  refcounts = ['_M_refcount']['_M_pi']
[New Thread 0x7ffff00c0700 (LWP 10014)]
D: zip_read.cpp:267: D: Registered VFS for prefix : /media/data/home/games/bios/PPSSPP/
[New Thread 0x7fffeca21700 (LWP 10015)]
[New Thread 0x7fffe7fff700 (LWP 10016)]

Thread 3 "ExecLoader" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffeca21700 (LWP 10015)]
0x00007fffeeb30628 in ByteReader::Read<AtlasHeader> (this=0x7fffeca20640)
    at ../ext/native/gfx/texture_atlas.cpp:13
13          memcpy(&x, data_ + offset_, sizeof(T));
(gdb) bt
#0  0x00007fffeeb30628 in ByteReader::Read<AtlasHeader> (this=0x7fffeca20640)
    at ../ext/native/gfx/texture_atlas.cpp:13
#1  0x00007fffeeb2ff2e in Atlas::Load (this=0x7fffef5d5c40 <g_ppge_atlas>, 
    data=0x0, data_size=0) at ../ext/native/gfx/texture_atlas.cpp:41
#2  0x00007fffee8614a5 in __PPGeInit () at ../Core/Util/PPGeDraw.cpp:237
#3  0x00007fffee728998 in __KernelInit () at ../Core/HLE/sceKernel.cpp:153
#4  0x00007fffee7601ce in __KernelLoadReset ()
    at ../Core/HLE/sceKernelModule.cpp:1636
#5  0x00007fffee76032c in __KernelLoadExec (
    filename=0x12082b0 "disc0:/PSP_GAME/SYSDIR/EBOOT.BIN", paramPtr=0, 
    error_string=0x7fffef5d5ab8 <coreParameter+120>)
    at ../Core/HLE/sceKernelModule.cpp:1663
#6  0x00007fffee8403d2 in <lambda()>::operator()(void) const (
    __closure=0x11ca028) at ../Core/PSPLoaders.cpp:302
#7  0x00007fffee843ab8 in std::__invoke_impl<void, Load_PSP_ISO(FileLoader*, std::string*)::<lambda()> >(std::__invoke_other, <lambda()> &&) (__f=...)
    at /usr/include/c++/9.2.0/bits/invoke.h:60
#8  0x00007fffee8439d7 in std::__invoke<Load_PSP_ISO(FileLoader*, std::string*)::<lambda()> >(<lambda()> &&) (__fn=...) at /usr/include/c++/9.2.0/bits/invoke.h:95
#9  0x00007fffee8438de in std::thread::_Invoker<std::tuple<Load_PSP_ISO(FileLoader*, std::string*)::<lambda()> > >::_M_invoke<0>(std::_Index_tuple<0>) (
    this=0x11ca028) at /usr/include/c++/9.2.0/thread:244
#10 0x00007fffee84385c in std::thread::_Invoker<std::tuple<Load_PSP_ISO(FileLoader*, std::string*)::<lambda()> > >::operator()(void) (this=0x11ca028)
    at /usr/include/c++/9.2.0/thread:251
#11 0x00007fffee84380c in std::thread::_State_impl<std::thread::_Invoker<std::tuple<Load_PSP_ISO(FileLoader*, std::string*)::<lambda()> > > >::_M_run(void) (
    this=0x11ca020) at /usr/include/c++/9.2.0/thread:195
#12 0x00007ffff3825b40 in ?? () from /usr/lib64/libstdc++.so.6
#13 0x00007ffff63ef06b in start_thread () from /lib64/libpthread.so.0
#14 0x00007ffff366672f in clone () from /lib64/libc.so.6

I bisected this issue.

There are only 'skip'ped commits left to test.
The first bad commit could be any of:
7e9578e49da4a0907dd4180510034d5f071c9e46
45d94c4877af970a45f2a939d63f56d0cb71b20f
We cannot bisect more

7e9578e49da4a0907dd4180510034d5f071c9e46 45d94c4877af970a45f2a939d63f56d0cb71b20f

Which is PR https://github.com/hrydgard/ppsspp/pull/12656.

What should happen?

It shouldn't crash.

What hardware, operating system, and PPSSPP version? On desktop, GPU matters for graphical issues.

OS: Slackware64-current GPU: RX Vega 56 CPU: AMD FX-6350 compiler: clang-10.0.0, gcc-9.2.0 mesa: https://github.com/mesa3d/mesa/commit/2d14a8f23721cba2f66ddecbece09a024dc1b45a llvm: 10.0.0 RetroArch: https://github.com/libretro/RetroArch/commit/f74126ec777abf8746d76857d57231bfbcb8850d

orbea commented 4 years ago

@hrydgard Given that this started after your PR maybe you have an idea what to do about this? Really the libretro port has been entirely broken at worst and poorly maintained at best for years now, is there any value in continuing down this path?

orbea commented 4 years ago

Actually never mind, I had it pointing to an old assets directory. Sorry for the noise.

orbea commented 4 years ago

Still maybe it shouldn't segfault and should error more gracefully? Please feel free to reopen.

hrydgard commented 4 years ago

Yes, you have a point there for sure. I'll fix the error check later.

Panderner commented 4 years ago

You forgot to add a Libretro label

LunaMoo commented 4 years ago

Actually this might not be libretro specific, it just happens it's not shipped with assets.

orbea commented 4 years ago

@hrydgard Please reopen this, its not yet fixed.

The problem is trying to run PPSSPP with old mismatched assets, not missing assets. This fixes a second crash later when trying to load a save game with missing assets, but it still crashes when the assets exist and are wrong (Too old).

Try reproducing this with the master and the assets directory from a commit before the bisect results in the OP.

hrydgard commented 4 years ago

Okay, fair enough.

unknownbrackets commented 4 years ago

It should not result in the same crash, because that crash happened with missing metadata and is fixed. But I did miss the case of missing ppge metadata only, see d2d07e253. Does it work now?

If it doesn't work, it's probably a different crash, and maybe even libretro specific. A new stack trace would help.

-[Unknown]

orbea commented 4 years ago

@unknownbrackets Yes after https://github.com/hrydgard/ppsspp/commit/d2d07e253b275a326e9035e77177a3635cd0a35d it now doesn't crash, thanks!