irixxxx/picodrive

Program doesn't work on x86_64 linux platforms (crash on startup)

Closed this issue · 7 comments

architecture x86_64
platform generic
sound drivers oss alsa sdl
C compiler gcc
C compiler flags -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -Wno-unused-result
libraries -L/usr/lib64 -lSDL -lasound -lpng -lm -lz -ldl
linker flags
libavcodec (mp3) no

Resulting binary executable does not work at all - empty window spawns, that causes other windows to go crazy as well (going black/transparent at random), additionally hogging CPU resources. In terminal output:
plat_sdl: using 1920x1080 as fullscreen resolution
plat_sdl: overlay: fmt 59565955, planes: 1, pitch: 1280, hw: 1
input: new device #0 "sdl:keys"
input: async-only devices detected..

drv probed binds name

0 0 y y sdl:keys
platform/libpicofe/readpng.c: unexpected font image size 256x320, needed 128x160
platform/libpicofe/readpng.c: unexpected selector image size 16x20, needed 8x10
found skin.txt
using sdl audio output driver
libpng warning: iCCP: known incorrect sRGB profile

OpenSuse tumbleweed x64, x11, linux kernel 6.2.

I don't have a real x86 machine at hand, but it works in a VM with both Ubuntu 16 and Ubuntu 22. Is this distribution specific? What packages for SDL 1.2 support are installed? Is an older version of picodrive working?

Strangley, it works on my VM with Ubuntu 22.10 as well! It might be related to openSUSE,as package names are completely confusing... will try later.
P.S. might attempt trying to build on Windows

What packages for SDL 1.2 support are installed?

libSDL-1_2-0 and libSDL_image-devel, also sdl2_compat-devel

Is an older version of picodrive working?

Picodrive 1.9.3 works perfectly,

Could you possibly bisect this? I can't do much without having at least a hint what's going on on your system.

Ah, I think I found the problem. Opensuse isn't using SDL1.2, but instead sdl12_compat on SDL2. And in their source repo is a bug:

SDL_FreeYUVOverlay(SDL12_Overlay *overlay12)
{
    if (overlay12) {
        SDL_Renderer *renderer = LockVideoRenderer();
        SDL12_YUVData *hwdata = (SDL12_YUVData *) overlay12->hwdata;
        QueuedOverlayItem *overlay = QueuedDisplayOverlays.next;
        while (overlay != NULL) {
            if (overlay->overlay12 == overlay12) {
                overlay->overlay12 = NULL;  /* don't try to draw this later. */
            }
        }

        if (renderer) {
            SDL20_DestroyTexture(hwdata->texture20);
            UnlockVideoRenderer();
        }

        SDL20_free(hwdata->pixelbuf);
        SDL20_free(overlay12);
    }
}

In the while lop there is an overlay = overlay->next missing, which leads to an endless loop. So, I guess without downloading the source package, fixing that bug and reinstalling from a locally build package your are out of luck :-/

BTW, the bug was fixed in libsdl-org/sdl12-compat in November:

184565a3 src/SDL12_compat.c  (Ryan C. Gordon 2022-08-26 10:42:42 -0400 7661)         while (overlay != NULL) {
184565a3 src/SDL12_compat.c  (Ryan C. Gordon 2022-08-26 10:42:42 -0400 7662)             if (overlay->overlay12 == overlay12) {
184565a3 src/SDL12_compat.c  (Ryan C. Gordon 2022-08-26 10:42:42 -0400 7663)                 overlay->overlay12 = NULL;  /* don't try to draw this later. */
184565a3 src/SDL12_compat.c  (Ryan C. Gordon 2022-08-26 10:42:42 -0400 7664)             }
683234e8 src/SDL12_compat.c  (Sam Lantinga   2022-11-17 07:55:07 -0800 7665)             overlay = overlay->next;
514ad86a src/SDL12_compat.c  (Ryan C. Gordon 2022-03-23 17:16:25 -0400 7666)         }

I see. Thanks for looking at it.

Hmm. Try removing all calls to SDL_FreeYUVOverlay. It's a rather ugly kludge, but it may work in this case.