FS#78819 - [dolphin-emu] Crashes on game start

Attached to Project: Arch Linux
Opened by nyanpasu64 (nyanpasu64) - Sunday, 18 June 2023, 10:15 GMT
Last edited by Toolybird (Toolybird) - Monday, 19 June 2023, 03:09 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To No-one
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
For unclear reasons, building with GCC 13 results in a Dolphin binary which crashes when trying to start a game with the JIT on (by default, and cached interpreter is too slow to play games). On the Dolphin discord, I've read:

> gcc 13 seems to have introduced some linker issues. Aside from Dolphin, it also affected rpcs3 as well as a few other projects.

In the meantime, people have found a workaround to setup CMake with `-DCMAKE_C_COMPILER=gcc-12 -DCMAKE_CXX_COMPILER=g++-12` (which requires adding gcc12 to the makedepends). This results in a working Dolphin binary.

There's a possibly-related upstream bug report at https://bugs.dolphin-emu.org/issues/13267 (with minimal information).

Steps to reproduce:
- Open a game
- Segfault

Note that the build fails with mbedtls installed (3.x is too new for Dolphin, https://bugs.dolphin-emu.org/issues/13124 not yet fixed) or libmgba installed (0.10.2 is too old for Dolphin, https://bugs.dolphin-emu.org/issues/13227 wontfix).
This task depends upon

Closed by  Toolybird (Toolybird)
Monday, 19 June 2023, 03:09 GMT
Reason for closing:  Duplicate
Additional comments about closing:   FS#78628 
Comment by Toolybird (Toolybird) - Sunday, 18 June 2023, 21:56 GMT
> - Segfault

Please post a backtrace with debug symbols [1]. Its usually as simple as the following (of course you must have gdb installed):

$ coredumpctl gdb (then answer y when it asks "Enable debuginfod for this session?")
(gdb) set logging enabled
(gdb) bt (or bt full)

Then post gdb.txt

[1] https://wiki.archlinux.org/title/Debugging/Getting_traces
Comment by nyanpasu64 (nyanpasu64) - Sunday, 18 June 2023, 22:07 GMT
I have a saved backtrace from earlier (before I installed a fixed Dolphin version). I think it's showing Jit64::Jit called from PowerPC assembly recompiled into x86 instructions, without a valid x86 call stack in parent frames.

```
(gdb) bt
#0 0x000056487f8146ff in Gen::XEmitter::Write8(unsigned char) (value=199 '\307', this=0x7f1a94486ac8) at /usr/src/debug/dolphin-emu/dolphin-emu/Source/Core/Common/x64Emitter.cpp:139
#1 Gen::OpArg::WriteNormalOp(Gen::XEmitter*, bool, Gen::NormalOp, Gen::OpArg const&, int) const (this=0x7f1aaeffa020, emit=0x7f1a94486ac8, toRM=true, op=Gen::NormalOp::MOV, operand=..., bits=32) at /usr/src/debug/dolphin-emu/dolphin-emu/Source/Core/Common/x64Emitter.cpp:1497
#2 0x000056487f3b31e8 in Jit64::mtspr(UGeckoInstruction) (this=0x7f1a944868a0, inst=...) at /usr/src/debug/dolphin-emu/dolphin-emu/Source/Core/Core/PowerPC/Jit64/Jit_SystemRegisters.cpp:302
#3 0x000056487f386424 in Jit64::CompileInstruction(PPCAnalyst::CodeOp&) (op=..., this=0x7f1a944868a0) at /usr/src/debug/dolphin-emu/dolphin-emu/Source/Core/Core/PowerPC/Jit64/Jit64_Tables.cpp:492
#4 Jit64::DoJit(unsigned int, JitBlock*, unsigned int) (this=this@entry=0x7f1a944868a0, em_address=em_address@entry=2147534764, b=b@entry=0x7f1a95291e38, nextPC=nextPC@entry=2147534792) at /usr/src/debug/dolphin-emu/dolphin-emu/Source/Core/Core/PowerPC/Jit64/Jit.cpp:1053
#5 0x000056487f387fcb in Jit64::Jit(unsigned int, bool) (this=0x7f1a944868a0, em_address=2147534764, clear_cache_and_retry_on_failure=true) at /usr/src/debug/dolphin-emu/dolphin-emu/Source/Core/Core/PowerPC/Jit64/Jit.cpp:757
#6 0x00007f16c8e7a0eb in ()
#7 0x0000000000000000 in ()
```

Other people have reported:

> Hmm... That indicates that when it's trying to JIT code, it's writing the resulting machine code to the wrong part of memory

> I think it's deeper than that, Dolphin interacts with the system more directly to get WX pages for the JIT

I'd think all the black magic flying around indicates that this isn't as simple as a basic wild-pointer bug.

Loading...