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

Segmentation fault on RPi5 with cpu_core=auto #488

Open
jonian opened this issue Mar 25, 2024 · 6 comments
Open

Segmentation fault on RPi5 with cpu_core=auto #488

jonian opened this issue Mar 25, 2024 · 6 comments

Comments

@jonian
Copy link

jonian commented Mar 25, 2024

Hi, when running dosbox-pure on an RPi5 device with dosbox_pure_cpu_core=auto, I get a segmentation fault error. Switching to cpu_core=normal fixes the issue.

My guess is that with the option set to auto, the core uses dynamic recompiler which is not supported on aarch64 (?).

@schellingb
Copy link
Owner

hmmm.. aarch64 is supported on Android though... maybe it's a build configuration issue?
I only have a RPi4 and I have not seen that, but now I'm not sure I tested in 32-bit or 64-bit mode.

I have received reports of eerily similar issues on Nintendo Switch. What's funny about Switch though is that it is possible to run Android on Switch and then the aarch64 Android core runs perfectly.

@jonian
Copy link
Author

jonian commented Mar 25, 2024

Thanks for the reply! I used the lakka scripts to build the core using docker, the armv7 builds using the same method work without issues. If you want me to test some builds I will be happy to do it.

The flags used to compile the core:

CFLAGS    : -march=armv8-a+crc -mabi=lp64 -Wno-psabi -mtune=cortex-a72 -mno-outline-atomics -Wall -pipe 
CXXFLAGS  : -march=armv8-a+crc -mabi=lp64 -Wno-psabi -mtune=cortex-a72 -mno-outline-atomics -Wall -pipe  
LDFLAGS   : -Wl,--as-needed 

If you would like to compile the core using my scripts:

git clone https://github.com/jonian/game.retroarch.git
cd game.retroarch

CORE=dosbox_pure ARCH=arm64 DEVICE=RPi5 sh libretro/build.sh

@jonian
Copy link
Author

jonian commented Mar 26, 2024

@schellingb after some searching, this might be an issue only on RPi5 due to this bug raspberrypi/bookworm-feedback#107, similar to:

flyinghead/flycast#1288
realnc/dosbox-core#57

@jonian jonian changed the title Segmentation fault on aarch64 with cpu_core=auto Segmentation fault on RPi5 with cpu_core=auto Mar 26, 2024
@jonian
Copy link
Author

jonian commented Mar 26, 2024

I can confirm that it works without issues if compiled with the flag:

-DPAGESIZE=16384

Ntemis pushed a commit to libretro/Lakka-LibreELEC that referenced this issue Mar 31, 2024
* DOSBox Pure 0.9.9

* Fix issue schellingb/dosbox-pure#488

* Set compiler flags properly
ToKe79 pushed a commit to libretro/Lakka-LibreELEC that referenced this issue Apr 10, 2024
* DOSBox Pure 0.9.9

* Fix issue schellingb/dosbox-pure#488

* Set compiler flags properly
@schellingb
Copy link
Owner

Thanks for looking into this and finding a fix!
Would there be a problem to set this on all aarch64 devices? My first instinct is to change our Makefile from

    PROCCPU := $(shell cat /proc/cpuinfo))
    ifneq ($(and $(filter ARMv7,$(PROCCPU)),$(filter neon,$(PROCCPU))),)
      CPUFLAGS := -marm -mcpu=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard -ffast-math

to

    UNAMEM := $(shell uname -m))
    ifeq ($(UNAMEM),aarch64)
      CPUFLAGS := -DPAGESIZE=16384
    else ifeq ($(UNAMEM), armv7l)
      CPUFLAGS := -marm -mcpu=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard -ffast-math

I only have a RPI4 but I have it running on a 64bit OS so I can try that on there and see if there's any issues.

@jonian
Copy link
Author

jonian commented May 16, 2024

I don't think that it is needed for every aarch64 device. Even on rpi5 it works with the 4k page size if you set kernel=kernel8.img in config.txt. Maybe the best approach is to check for the page size at build time using:

shell getconf PAGESIZE

This is how it was fixed in flycast and dosbox-core.

flyinghead/flycast@0f6a92c
realnc/dosbox-core@1e6a675

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants