Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[macOS] [Arm Native] LLVM: Segfault before launching any game #12882

Closed
shinra-electric opened this issue Oct 25, 2022 · 14 comments
Closed

[macOS] [Arm Native] LLVM: Segfault before launching any game #12882

shinra-electric opened this issue Oct 25, 2022 · 14 comments

Comments

@shinra-electric
Copy link
Contributor

shinra-electric commented Oct 25, 2022

Quick summary

RPCS3 will segfault when trying to launch any game.

Edit: Segfault doesn't happen if:

  • PPU Decoder is set to Static Interpreter
  • SPU Decoder is set to Dynamic Interpreter

Edit: After the LLVM 16 update, it's no longer Ventura-only. LLVM fails on Ventura and Monterey.

Details

RPCS3 will segfault with the following error on launching any game. You can see that the segfault location is the same, though the thread may be different:

For Demon's Souls:

F {PPU[0x1000005] Thread (HighGraphics) [libgcm_sys: 0x01fc0c78]} SIG: Thread terminated due to fatal error: Segfault writing location 0000000000000018 at 000000712003a4ec.
Emu Thread Name: 'PPU[0x1000005] HighGraphics'.

For Dragon's Crown:

F {PPU[0x1000000] Thread (main_thread) [libgcm_sys: 0x00f90c78]} SIG: Thread terminated due to fatal error: Segfault writing location 0000000000000018 at 000000710002a4ec.
Emu Thread Name: 'PPU[0x1000000] main_thread'.

Build with regression

Unknown

Edit: This is likely to do with Ventura, and not an RPCS3 regression
Edit: After the LLVM 16 update, it's no longer Ventura-only. LLVM fails on Ventura and Monterey.

Attach two log files

RPCS3.log

Edit: New log from after the LLVM 16 update:
RPCS3.log

System configuration

M1 Pro, macOS 13 Ventura

Other details

I cannot identify the commit that introduced the regression since there are currently no Arm builds in CI.

It likely happened between #12620 and now. That PR broke Arm compilation and it has only been fixed yesterday.

Edit: This is likely to do with Ventura, and not an RPCS3 regression
Edit: After the LLVM 16 update, it's no longer Ventura-only. LLVM fails on Ventura and Monterey.

@Soneoylys
Copy link

Can be reproduced in latest commit, build on M1 Apple Silicon with cmake arg
"-DPNG_ARM_NEON=on -DUSE_ALSA=OFF -DUSE_PULSE=OFF -DUSE_AUDIOUNIT=ON -DUSE_NATIVE_INSTRUCTIONS=OFF -DUSE_SYSTEM_FFMPEG=on -DCMAKE_OSX_ARCHITECTURES="arm64" -DLLVM_TARGETS_TO_BUILD="X86;AArch64;ARM" -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUSE_SYSTEM_MVK=on"

Tried to run with static PPU/SPU decoder, which able to boot into game, but missing all 3D graphics.

Also, please consider to add native aarch64 release in CI if possible, Rosetta significant reduce the CPU performance which is usually a bottleneck in PS3 emulation.

@shinra-electric
Copy link
Contributor Author

shinra-electric commented Jan 17, 2023

I think this may be related to Ventura.

I just made a build on Ventura now and it failed as described above.

Screenshot 2023-01-17 at 14 37 56

But I also made a build at the same time on Monterey in a VM, and it went in-game.

Screenshot 2023-01-17 at 13 04 38

It actually crashed shortly after that, but that crash was unrelated.

Can anyone else with an M1 and Monterey confirm this?

@nsklaus
Copy link

nsklaus commented Feb 8, 2023

for what it's worth, i was able to start playing "the last of us" on macbookpro M2 (14" 2023 model)

- SYS: RPCS3 v0.0.26-14691-27cad422 Alpha | master
- SYS: VirtualApple @ 2.50GHz | 10 Threads | 16.00 GiB RAM | TSC: 1.000GHz
- SYS: Operating system: macOS, Version: 13.2.0
- SYS: Current Time: 2023-02- 8T21:59:35
- RSX: Found vulkan-compatible GPU: 'Apple M2 Pro' running on driver 0.2.986
- SYS: Firmware version: 4.89

the game did start, and i played for a minute or so, i thought i'd try to tweak a bit more settings so i did quit game, and after that it could never be started again. no matter what i did with settings.. reverting back to previously working ones, default, or even tweak more, nothing worked.
i get no segfault or complete crashes when atttempting to start the game again, just, after the compiling shaders progress bar, i get a black game window and no sound, fps on the titlebar are getting updated but nothing gets displayed in the window. and i cannot properly stop emulation or quit rpcs3, i have to force quit it.

let me know if you need more logs, or running some tests.

@nsklaus
Copy link

nsklaus commented Feb 8, 2023

hmm.. ok, if i delete the configuration directory in ~/Library/Application\ Support/rpcs3/ game is starting again. each time i want to play i have to delete that directory. maybe i could manage to make a backup copy of gamesaves before deleting that dir and import them in the freshly created one ?
i'll have to test. also, in the manage patches panel, i disabled motion blur, but the game still have them. so i'm not sure patches are correctly applied either.

macos_rpcs3_last_of_us.log

after the game ran the first time, i can no longer start it again as i was saying above, and when i try anyway (to start the game again) then rpcs3 shows a black game window, and if i try to stop emulation or quit rcps3 then app becomes unresponsive, and i see in the log panel messages like this:
E sys_fs: 'sys_fs_open' failled with 0x80010006 : CELL_ENOENT, "/dev_hdd0/game/BCES01585DATA2/USRDIR/users/VXNIcg==/autosave/10.save" [1]

@shinra-electric
Copy link
Contributor Author

shinra-electric commented Feb 9, 2023

  • SYS: RPCS3 v0.0.26-14691-27cad422 Alpha | master

It looks to me like you are testing the CI builds, which are x86 and run through Rosetta.
This issue is regarding Arm builds that have to be built yourself locally. There are no Arm CI build at this time.

If you want to test an Arm build, here are the build instructions:

RPCS3 Build instructions.txt

Edit:
From your logs I confirmed you are running the x86 build:

S PPU: LLVM: Loaded module v5-kusa-cgTCsTW4KQRTqTpnpGSmqN-00001P-westmere.obj

If it was the Arm build it would compile the modules for the cyclone architecture, not westmere.

@nsklaus
Copy link

nsklaus commented Feb 9, 2023

ah, my bad :)
yes i was running x86, provided CI builds.
i had assumed you were all using provided (x86) builds too and just happened to use them on arm (m1/m2) machines. thank you for pointing me to the build instructions.

@shinra-electric shinra-electric changed the title [Regression] [macOS] [Arm] Segfault before launching any game [macOS] [Arm Native] [Ventura only] Segfault before launching any game Feb 9, 2023
@shinra-electric
Copy link
Contributor Author

I renamed the issue to make it a bit clearer

@nsklaus
Copy link

nsklaus commented Feb 9, 2023

yes sorry about the confusion and my posts completely off target.
can i ask, how much of a boost native builds used to show compared to x86 ones ?
+5fps or so in a test game ?
it was very interesting to see rpcs3 could run games like 'last of us' on mac.
the fps though were around 10 to 20, but the machine barely got warm, i suppose there's room for optimisations later on ? there were quite a few gfx errors, texture 'popping' and flashing around. the game was overall looking normal, but with glitches here and there appearing and disappearing constantly. i'll try to see if i can make my own native build.

@shinra-electric
Copy link
Contributor Author

If you can make your own build, please post how it goes. But I suspect it will not launch any games for you due to this issue.

The Arm build (when it works) can only play a handful of 2D games at this time. I usually test with Dragon's Crown, and the Arkedo series also work. Maybe some other 2D games I haven't tested work as well. It will not play any 3D games without further development.

@nsklaus
Copy link

nsklaus commented Feb 9, 2023

i see, thank you for those details. i bet both x86 and arm builds make use of same libs. most probably moltenvk, i wonder what differs that much as to break 3d completely for arm builds.
maybe it have to do with memory pages that are 16k on the M series ? but if that would be something like that, then probably nothing would run, not even 2d. so i guess it must be something else.. it's not that i have the knowledge to fix it anyway, but it got me curious. has anyone pinpointed the root cause of this yet ? shouldn't be that big of an issue. is there a specific thread for that particular problem ?
having native arm builds, with 3d and all the bells and whistle would surely be nice to have.

@zintus
Copy link

zintus commented Feb 11, 2023

I was able to build 465ca9753 locally on m2 using instructions from #12115

Game halt immediately with F {SPU[0x1000100] Thread (PrimaryCellSpursKernel1) [0x06600]} SIG: Thread terminated due to fatal error: Segfault writing location 0000000000000000 at 0000000f0005c834. Emu Thread Name: 'SPU[0x1000100] PrimaryCellSpursKernel1'.

rpcs3.log

I hope this helps :)

@shinra-electric
Copy link
Contributor Author

Thanks for testing, though I expected it to fail on Ventura.

If anyone can test with Monterey, that would be great. If we can confirm the issue is with a change in macOS, that would help identify the issue.

@shinra-electric
Copy link
Contributor Author

shinra-electric commented Apr 4, 2023

I tried using different options for the PPU and SPU decoders, and found that RPCS3 will not exhibit this segfault issue if:

  • PPU Decoder is set to Static Interpreter
  • SPU Decoder is set to Dynamic Interpreter

Screenshot 2023-04-04 at 18 00 03

Screenshot 2023-04-04 at 18 20 15

@shinra-electric shinra-electric changed the title [macOS] [Arm Native] [Ventura only] Segfault before launching any game [macOS] [Arm Native] LLVM: Segfault before launching any game Apr 16, 2023
@kd-11
Copy link
Contributor

kd-11 commented Aug 25, 2024

Fixed by #15992 and #15987

@kd-11 kd-11 closed this as completed Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants