turanszkij / WickedEngine

3D engine with modern graphics
https://wickedengine.net
Other
5.83k stars 618 forks source link

Linux: segfault on window-close / quit #792

Open metaleap opened 10 months ago

metaleap commented 10 months ago

(Since this happens only on-quit, I guess it isn't too critical/urgent... but for completeness' sake I'll file it here =)

With a libWickedEngine_Linux.so Release-with-Debug-symbols build labelling itself on-window as v0.71.357 (~late Dec master branch iirc), Linux (6.6.10-zen1-1-zen) with X11 (not Wayland), NVIDIA RTX 4090 driver 545.29.06.

Based on Template_Linux, this minimalist main.cpp, which is the only source file in this program:

#include <cstdio>

#include <SDL2/SDL.h>
#include <WickedEngine.h>

void mainLoop(wi::Application&);

int main() {
    wi::renderer::SetShaderSourcePath("../libdeps/WickedEngine/WickedEngine/shaders/");
    wi::renderer::SetShaderPath("../.cache/shaders/");

    wi::Application app;
    app.infoDisplay.active = true;
    app.infoDisplay.watermark = true;
    app.infoDisplay.resolution = true;
    app.infoDisplay.fpsinfo = true;

    sdl2::sdlsystem_ptr_t sdl_sys = sdl2::make_sdlsystem(SDL_INIT_EVERYTHING | SDL_INIT_EVENTS);
    sdl2::window_ptr_t sdl_win = sdl2::make_window("HeloWick", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1440, 960,
                                                   SDL_WINDOW_SHOWN | SDL_WINDOW_VULKAN | SDL_WINDOW_ALLOW_HIGHDPI
                                                       | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE);
    app.SetWindow(sdl_win.get());
    mainLoop(app);
    SDL_Quit();
    return 0;
}

void mainLoop(wi::Application& app) {
    SDL_Event sdl_evt;

    bool quit = false;
    while (!quit) {
        SDL_PumpEvents();
        app.Run();

        while (SDL_PollEvent(&sdl_evt))
            switch (sdl_evt.type) {
                case SDL_QUIT:
                    quit = true;
                    break;
                case SDL_WINDOWEVENT:
                    switch (sdl_evt.window.event) {
                        case SDL_WINDOWEVENT_CLOSE:
                            quit = true;
                            break;
                        case SDL_WINDOWEVENT_RESIZED:
                            app.SetWindow(app.window);
                            break;
                    }
                    break;
            }
    }
}

segfaults on Alt+F4 (does jump into SDL_WINDOWEVENT_CLOSE case) with gdb debugger breaking/line-highlighting at WickedEngine/wiGraphicsDevice_Vulkan.h#L518

Output in VSCode's Debug Console:

1 "mo3d.exec" received signal SIGSEGV, Segmentation fault.
0x00007ffff6aaddb4 in pthread_mutex_lock () from /usr/lib/libc.so.6
klaussilveira commented 7 months ago

Which SDL version are you using? Did you build it yourself, or are you using your distro's? If the distro one, which distro?