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

Crash when closing game when manually triggered NewGRF scan in operation #8833

Closed
JGRennison opened this issue Mar 9, 2021 · 1 comment · Fixed by #8830
Closed

Crash when closing game when manually triggered NewGRF scan in operation #8833

JGRennison opened this issue Mar 9, 2021 · 1 comment · Fixed by #8830

Comments

@JGRennison
Copy link
Contributor

Version of OpenTTD

master (b21ba56)

SDL2 on Linux (with default OpenGL driver and blitter)

Expected result

No crash when closing game when manually triggered NewGRF scan in operation

Actual result

Thread 1 "openttd" received signal SIGSEGV, Segmentation fault.
0x00005555663e48eb in VideoDriver_SDL_OpenGL::ClearSystemSprites (this=0x61a000000680) at /home/jgr/misc/openttd-6/src/video/sdl2_opengl_v.cpp:120
120		OpenGLBackend::Get()->ClearCursorCache();
(gdb) bt
#0  0x00005555663e48eb in VideoDriver_SDL_OpenGL::ClearSystemSprites (this=0x61a000000680) at /home/jgr/misc/openttd-6/src/video/sdl2_opengl_v.cpp:120
#1  0x0000555566a0ae66 in GfxLoadSprites () at /home/jgr/misc/openttd-6/src/gfxinit.cpp:335
#2  0x00005555661e94c9 in ReloadNewGRFData () at /home/jgr/misc/openttd-6/src/saveload/afterload.cpp:3165
#3  0x0000555567070d5f in NewGRFWindow::~NewGRFWindow (this=0x616001ab6280, __in_chrg=<optimised out>) at /home/jgr/misc/openttd-6/src/newgrf_gui.cpp:669
#4  0x0000555567071280 in NewGRFWindow::~NewGRFWindow (this=0x616001ab6280, __in_chrg=<optimised out>) at /home/jgr/misc/openttd-6/src/newgrf_gui.cpp:674
#5  0x0000555567e65bde in UnInitWindowSystem () at /home/jgr/misc/openttd-6/src/window.cpp:1923
#6  0x000055556727021b in ShutdownGame () at /home/jgr/misc/openttd-6/src/openttd.cpp:310
#7  0x0000555567275977 in openttd_main (argc=2, argv=0x7fffffffdbd8) at /home/jgr/misc/openttd-6/src/openttd.cpp:865
#8  0x000055556604b9eb in main (argc=2, argv=0x7fffffffdbd8) at /home/jgr/misc/openttd-6/src/os/unix/unix.cpp:265

I get an identical crash with #8830 applied, so that PR doesn't fix this sadly.

Steps to reproduce

  1. Open the game.
  2. Wait for the NewGRF scan to complete.
  3. Go to the NewGRF settings window
  4. Manually trigger another scan
  5. Close the window to exit the game
@TrueBrain
Copy link
Member

This backtrace is a bit funny. Basically, the game is already shutting down, but the NewGRF window decides it is a good idea to reload everything. As I mean, why not, right? :D

ShutdownGame however, first shuts down all the drivers, so the OpenGL context is released by now. Only after that the Window system is destroyed.

I see two solutions:

  1. destroy windows first, before we destroy the video driver
  2. add an if (!_exit_game) in NewGRFWindow to prevent a ReloadNewGRFData

The second might be the most useful, as it is stupid to do either way. The first is the cheapskate solution, as it doesn't change anything really, so nothing could possibly break (famous last words). I included the second solution in #8830 now.

TrueBrain added a commit to TrueBrain/OpenTTD that referenced this issue Mar 9, 2021
Otherwise that might cause calls to the video-driver, which are
already shut down by now. This causes, depending on the video-driver
crashes or weird effects.
TrueBrain added a commit to TrueBrain/OpenTTD that referenced this issue Mar 9, 2021
Otherwise that might cause calls to the video-driver, which are
already shut down by now. This causes, depending on the video-driver
crashes or weird effects.
TrueBrain added a commit to TrueBrain/OpenTTD that referenced this issue Mar 9, 2021
Otherwise that might cause calls to the video-driver, which are
already shut down by now. This causes, depending on the video-driver
crashes or weird effects.
TrueBrain added a commit that referenced this issue Mar 10, 2021
Otherwise that might cause calls to the video-driver, which are
already shut down by now. This causes, depending on the video-driver
crashes or weird effects.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants