AdvMame 3.9 SIGSEGV on exit in default Retropie distribution on RPi 4
Brought to you by:
amadvance
The current version of AdvMame in the Retropie distribution (3.9) crashes on exit quite reliably if the misc_smp setting is true on the Raspberry Pi 4. (SIGSEGV is logged to /dev/shm/runcommand.log). This keeps configuration changes from being written out unless SMP is turned off first, and then back on before the next launch. Unfortunately, because RetroPie's emulationstation relies on the DRM/KMS driver, it's not practical to disable that in config.txt in order to allow for a real frame buffer, and video in advmame must be set to SDL. Because of that, it appears that performance is negatively impacted unless SMP is actually enabled.
Hi Andy
I tried on my Raspberry 4, and it looks like working well. Can you replicate the issue with the git version of AdvanceMAME on a standard Raspbian ?
If yes, in what condition exactly ? I tried from both cmdline, window environment fullscreen, and also in a window (-output window), but everything looks like working.
Ciao,
Andrea
Last edit: Andrea Mazzoleni 2023-03-23
The situation is that if Advmame is started in SMP mode on the Pi4 in the RetroPie environment (I.e. launched by command line via EmulationStation) then when you go to exit the emulator it crashes during exit at some point before any config file changes made during the session are are written out. Any ROM, doesn't matter which one. RetroPie does not use any windowing system, it relies on the DRM/KMS drivers as the bug states to run EmulationStation, and the Advmame config must use SDL.
Happy to provide more info if that's not specific enough for you- I have two separate Pi4s using the stock RetroPie distribution which both exhibit this behavior so it should be easy to reproduce as long as the environment matches as described above.
Last edit: Andy Silverman 2023-03-25
Hi Andy,
Have you tried the git version of AdvanceMAME ? It has changes specific for the Raspberry 4. You have to build if from source.
Also, try to run AdvanceMAME directly from the command line and not from EmulationStation, and check if the problem is still here.
When building AdvanceMAME, you can also use the ./configure --enable-debug, that will report more information after a crash. That info will help to get an understanding of the problem.
Ciao,
Andrea
Yes, I’ve used the git version and enabled debug but for some reason that SIGSEV is all that is reported if I remember correctly. Stack corrupted? I did try to debug it further but didn't get very far. I'll try again and make sure.
Last edit: Andy Silverman 2023-03-25
Spent some time reproducin the bug again today. Here's what I encountered: When retropie determines that you're running on a Pi4 it compiles the git version with the following configure flags: --enable-sdl2 --disable-sdl --disable-vc because it expects the PI4 to use the DRM/KMS video driver, not videocore. So I built from the github master with those options plus --enable-debug. (Without those options you get an error from advmame when running from the command line that you need to run under a window manager to use the SDL option. Retropie doesn't use a window manager, it effectively command-line launches all emulators.)
Ran pacman, exited, and you get:
I then edited the configure.ac file to dnl the line where it specifies -fomit-frame-pointer on the Pi4. (Perhaps the script should do so automatically when the --enable-debug flag is provided?) It looks like LDFLAGS already has -rdynamic within the configure script. make clean, re-run...
The result is the same (no stack backtrace, etc. ) At this point I'm happy to try anything you like to gather more info- the problem is quite simple to reproduce but it seems hard to get any more useful debug info.
Hi Andy,
With the --disable-vc I'm able to replicate the issue. I'm able to work around it using the option -nodisplay_restore that tells AdvanceMAME to not restore the video mode at the exit.
But take care that AdvanceMAME still uses the framebuffer, unless you build with --disable-fb. It just uses it without the VideoCore interface. So, I'm not sure that you are really using the SDL.
If even with -nodisplay_restore you have problem, try also with -logsync that writes the advmame.log file. Attach it here.
Ciao,
Andrea
Crash still occurs with "display_restore no" added to the .rc file in my case, but I was still able to get a log with -logsync, attached below. The log appears to end normally in spite of the crash, but you can see for yourself whether there's anything unexpected.
Just to see what would happen, I then rebuilt with --disable-fb (in addition to --enable-debug, --enable-sdl2, --disable-sdl, --disable-vc. After removing a couple of now "unknown options" in the .rc, the emulator still runs in SMP albeit with somewhat worse performance (an occasional odd freeze for a few seconds) and still crashes on exit, so that wasn't really an improvement despite removal of the fb support.