xyproto / zsnes

A maintained fork of ZSNES, a Super Nintendo emulator. The original project needs patches to build and is not maintained anymore: https://sourceforge.net/projects/zsnes/
https://zsnes.com
GNU General Public License v2.0
131 stars 16 forks source link

Segmentation fault on Fedora 37 #11

Closed llgxela closed 1 year ago

llgxela commented 1 year ago

Hello,

ZSNES segfaults immediately during startup on Fedora 37. I don't know if the same happens on the 36 release, but on Fedora 35 it was working fine. Please tell me if I can do something to help.

Thanks

xyproto commented 1 year ago

Thanks for reporting.

Do you happen to know if the package depends on sdl2 or sdl1? There is a compatability package that can be used to compile it so that it uses sdl2.

Also, do you use Pipewire? It could be an audio related problem.

Compiling with debug flags, running with "gdb" and then getting a backtrace would also be useful. A bit like this: https://wiki.archlinux.org/title/Debugging/Getting_traces

llgxela commented 1 year ago

I'm using Pipewire, but it became default on Fedora 34 if I remember correctly.

This is the stack trace (I hope I got it right, I'm not an expert with gdb):

Reading symbols from zsnes... (gdb) r Starting program: /home/alessandro/Downloads/zsnes-2.0.10/zsnes /home/alessandro/roms/snes/example.sfc

This GDB supports auto-downloading debuginfo from the following URLs: https://debuginfod.fedoraproject.org/ Enable debuginfod for this session? (y or [n]) Debuginfod has been disabled. To make this setting permanent, add 'set debuginfod enabled off' to .gdbinit. [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". Could not load: /home/alessandro/roms/snes/example.sfc [New Thread 0xf6a0cb40 (LWP 5111)] [New Thread 0xeccbeb40 (LWP 5116)] [New Thread 0xec2ffb40 (LWP 5117)] [New Thread 0xebafeb40 (LWP 5118)] [New Thread 0xeb0ffb40 (LWP 5119)] [New Thread 0xea4ffb40 (LWP 5120)] [New Thread 0xe9cfeb40 (LWP 5121)] [New Thread 0xe94fdb40 (LWP 5122)] [New Thread 0xe88ffb40 (LWP 5123)] [Thread 0xe88ffb40 (LWP 5123) exited] [New Thread 0xe88ffb40 (LWP 5124)]

Thread 1 "zsnes" received signal SIGSEGV, Segmentation fault. 0x00000000 in ?? () Missing separate debuginfos, use: dnf debuginfo-install SDL2-2.26.3-1.fc37.i686 dbus-libs-1.14.6-1.fc37.i686 elfutils-libelf-0.189-1.fc37.i686 expat-2.5.0-1.fc37.i686 glibc-2.36-9.fc37.i686 libX11-1.8.4-1.fc37.i686 libX11-xcb-1.8.4-1.fc37.i686 libXau-1.0.10-1.fc37.i686 libXext-1.3.4-9.fc37.i686 libXfixes-6.0.0-4.fc37.i686 libXrandr-1.5.2-9.fc37.i686 libXrender-0.9.10-17.fc37.i686 libXxf86vm-1.1.4-19.fc37.i686 libcap-2.48-5.fc37.i686 libdecor-0.1.1-1.fc37.i686 libdrm-2.4.114-1.fc37.i686 libedit-3.1-43.20221009cvs.fc37.i686 libffi-3.4.4-1.fc37.i686 libgcc-12.2.1-4.fc37.i686 libglvnd-1.5.0-1.fc37.i686 libglvnd-glx-1.5.0-1.fc37.i686 libpciaccess-0.16-7.fc37.i686 libpng-1.6.37-13.fc37.i686 libselinux-3.5-1.fc37.i686 libstdc++-12.2.1-4.fc37.i686 libwayland-client-1.21.0-1.fc37.i686 libwayland-cursor-1.21.0-1.fc37.i686 libxcb-1.13.1-10.fc37.i686 libxshmfence-1.3-11.fc37.i686 libzstd-1.5.5-1.fc37.i686 lz4-libs-1.9.4-1.fc37.i686 mesa-dri-drivers-22.3.7-1.fc37.i686 mesa-libGL-22.3.7-1.fc37.i686 mesa-libglapi-22.3.7-1.fc37.i686 ncurses-libs-6.3-4.20220501.fc37.i686 sdl12-compat-1.2.60-1.fc37.i686 systemd-libs-251.14-2.fc37.i686 xz-libs-5.4.1-1.fc37.i686 zlib-1.2.12-5.fc37.i686 (gdb) bt full

0 0x00000000 in ?? ()

No symbol table info available.

1 0xf7644b19 in WarpMouseInternal () from /lib/libSDL2-2.0.so.0

No symbol table info available.

2 0xf7580c34 in SDL_PerformWarpMouseInWindow () from /lib/libSDL2-2.0.so.0

No symbol table info available.

3 0xf7e1a83e in SDL_WarpMouse () from /lib/libSDL-1.2.so.0

No symbol table info available.

4 0x082e2ed8 in sw_start (width=512, height=448, req_depth=16, FullScreen=0) at linux/sw_draw.c:70

    flags = 1073741825
    GBitMask = <optimized out>

5 0x082e2207 in startgame () at linux/sdllink.c:1028

    ranonce = true
    status = <optimized out>

6 0x082e2775 in initwinvideo () at linux/sdllink.c:1221

    newmode = 1

7 0x082e013b in initvideo () at linux/c_sdlintrf.c:193

    firstvideo = 1

8 0x082a4c0c in start65816 () at cpu/c_execute.c:41

No locals.

9 0x082950b6 in init () at c_init.c:159

    vol = <optimized out>

10 0x082cb6e1 in zstart () at ui.c:361

    ptr = <synthetic pointer>

11 0x082d7958 in main (argc=2, argv=0xffffcfd4) at zloader.c:975

No locals.

Edit: I'm using the sdl12-compat-* devel packages.

Thanks

xyproto commented 1 year ago

Thanks. I'll install Fedora in a VM and try to reproduce the issue.

xyproto commented 1 year ago

I tried running it in Fedora 38 x86_64 in QEMU and got this:

[...]
Enable debuginfod for this session? (y or [n]) y
Debuginfod has been enabled.
To make this setting permanent, add 'set debuginfod enabled on' to .gdbinit.
[Thread debugging using libthread_db enabled]                                                                                                                                                             
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0xf6797b40 (LWP 8957)]                                                                                                                                                                        

Thread 1 "zsnes" received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()
(gdb) bt full
#0  0x00000000 in ?? ()
No symbol table info available.
#1  0xf7638cf6 in Wayland_VideoInit (_this=0x8a01d50) at /usr/src/debug/SDL2-2.26.3-1.fc38.i386/src/video/wayland/SDL_waylandvideo.c:965
        data = 0x8a01cc0
#2  0xf75eb4d2 in SDL_VideoInit_REAL (driver_name=<optimized out>) at /usr/src/debug/SDL2-2.26.3-1.fc38.i386/src/video/SDL_video.c:527
        video = 0x8a01d50
        init_events = SDL_TRUE
        init_keyboard = SDL_TRUE
        init_mouse = SDL_TRUE
        init_touch = SDL_TRUE
        i = <optimized out>
        pre_driver_error = <optimized out>
#3  0xf75300b3 in SDL_InitSubSystem_REAL (flags=<optimized out>) at /usr/src/debug/SDL2-2.26.3-1.fc38.i386/src/SDL.c:253
        flags_initialized = <optimized out>
#4  0xf7e0f5f7 in SDL_InitSubSystem (sdl12flags=32) at /usr/src/debug/sdl12-compat-1.2.60-3.fc38.i386/src/SDL12_compat.c:2416
        sdl20flags = 32
        rc = <optimized out>
#5  0xf7e0f9b8 in SDL_Init (sdl12flags=32) at /usr/src/debug/sdl12-compat-1.2.60-3.fc38.i386/src/SDL12_compat.c:2444
No locals.
#6  0x082e0fb6 in startgame () at linux/sdllink.c:1021
        ranonce = true
        status = <optimized out>
#7  0x082e1549 in initwinvideo () at linux/sdllink.c:1221
        newmode = 1
#8  0x082deed8 in initvideo () at linux/c_sdlintrf.c:193
        firstvideo = 1
#9  0x082a3ac9 in start65816 () at cpu/c_execute.c:41
No locals.
#10 0x0829408c in init () at c_init.c:159
        vol = <optimized out>
#11 0x082ca574 in zstart () at ui.c:361
        ptr = <synthetic pointer>
#12 0x082d6751 in main (argc=2, argv=0xffffd144) at zloader.c:975
No locals.
(gdb) 

It looks like things might be taking a left turn in SDL_Init. Perhaps it's connected to Wayland, OpenGL or sdl12-compat somehow.

I guess the way forward is to continue working on the sdl2 branch, which ports ZSNES to SDL2.

And testing it under X11, possibly under Xfce4, is also a possibility. I can also double check if it works on Arch Linux in Sway using Wayland and sdl12-compat. It works on Arch under Xfce4.

xyproto commented 1 year ago

Under Xfce4 in the same Fedora 38 VM I get:

Enable debuginfod for this session? (y or [n]) y
Debuginfod has been enabled.
To make this setting permanent, add 'set debuginfod enabled on' to .gdbinit.
[Thread debugging using libthread_db enabled]                                       
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0xf6797b40 (LWP 15192)]                                                 
[New Thread 0xebbffb40 (LWP 15204)]                                                 

Thread 1 "zsnes" received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()
(gdb) bt full
#0  0x00000000 in ?? ()
No symbol table info available.
#1  0xf7619599 in WarpMouseInternal (xwindow=29360136, x=128, y=112)
    at /usr/src/debug/SDL2-2.26.3-1.fc38.i386/src/video/x11/SDL_x11mouse.c:324
        videodata = 0x8a0dbe0
        display = 0x89fe1c0
        deviceid = 0
#2  0xf7557fe4 in SDL_PerformWarpMouseInWindow (window=<optimized out>, 
    x=<optimized out>, y=<optimized out>, ignore_relative_mode=SDL_FALSE)
    at /usr/src/debug/SDL2-2.26.3-1.fc38.i386/src/events/SDL_mouse.c:1063
        mouse = 0xf7700740 <SDL_mouse.lto_priv.0>
#3  0xf7e1a9fe in SDL_WarpMouse (y=<optimized out>, x=<optimized out>)
    at /usr/src/debug/sdl12-compat-1.2.60-3.fc38.i386/src/SDL12_compat.c:7136
No locals.
#4  SDL_WarpMouse (x=128, y=112)
    at /usr/src/debug/sdl12-compat-1.2.60-3.fc38.i386/src/SDL12_compat.c:7129
No locals.
#5  0x082e1cac in sw_start (width=512, height=448, req_depth=16, FullScreen=0)
    at linux/sw_draw.c:70
        flags = 1073741825
        GBitMask = <optimized out>
#6  0x082e0fdb in startgame () at linux/sdllink.c:1028
        ranonce = true
        status = <optimized out>
#7  0x082e1549 in initwinvideo () at linux/sdllink.c:1221
        newmode = 1
#8  0x082deed8 in initvideo () at linux/c_sdlintrf.c:193
        firstvideo = 1
#9  0x082a3ac9 in start65816 () at cpu/c_execute.c:41
No locals.
#10 0x0829408c in init () at c_init.c:159
        vol = <optimized out>
#11 0x082ca574 in zstart () at ui.c:361
        ptr = <synthetic pointer>
#12 0x082d6751 in main (argc=2, argv=0xffffd044) at zloader.c:975
No locals.
(gdb) 

If the call to SDL_WarpMouse can be disabled, perhaps it will work under X again on Fedora 38.

xyproto commented 1 year ago

Not calling SDL_WarpMouse did the trick in the Fedora 38 x86_64 VM I have here.

Please test.