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

Random map generation failure crashes the game (dedicated server). #7646

Closed
James103 opened this issue Jul 10, 2019 · 6 comments

Comments

@James103
Copy link
Contributor

@James103 James103 commented Jul 10, 2019

Version of OpenTTD

1.9.2 and master-20190707

Expected result

Random map generation failure should either cause the next attempt to use a random seed that should hopefully succeed (regardless of if a set seed was input into the "newmap" / "newgame" command) or for the game to exit and/or restart.

Actual result

Random map generation failure crashes the game with NOT_REACHED triggered at line 140 of d:\a\1\s\src\thread\thread_win32.cpp while in a dedicated server. Crash info has been attached.

Steps to reproduce

Set the map generation settings as follows (from my openttd.cfg):

town_name = 21
landscape = temperate
snow_line_height = 15
starting_year = 3000
land_generator = 1
oil_refinery_limit = 48
tgen_smoothness = 3
variety = 0
generation_seed = 32
tree_placer = 0
heightmap_rotation = 0
se_flat_world_height = 1
map_x = 6
map_y = 6
water_borders = 15
custom_town_number = 5000
custom_sea_level = 90
min_river_length = 16
river_route_random = 5
amount_of_rivers = 0

Then, run openttd -D ::1 (dedicated server) and type newmap 32 or newgame 32 into the console. If that doesn't work, try some other seeds/settings. If the map generation fails, then the game crashes.

@LordAro

This comment has been minimized.

Copy link
Member

@LordAro LordAro commented Jul 11, 2019

Interesting that it also crashes in master, given the threading code has been rewritten since 1.9.x. Presumably the error message is different, as thread_win32.cpp doesn't exist anymore :)

@James103

This comment has been minimized.

Copy link
Contributor Author

@James103 James103 commented Jul 11, 2019

@LordAro
I haven't tested master (20190707) yet when you made your comment. Actually, OpenTTD master (20190707-master- 1e72393) does crash (Assertion failed at line 61 of d:\a\1\s\src\newgrf_storage.cpp: ignore_prev_mode || !gameloop) when random map generation fails as a dedicated server. Crash logs and console log has been attached.

@James103

This comment has been minimized.

Copy link
Contributor Author

@James103 James103 commented Jul 11, 2019

I can't give you the full stacktrace, but I can tell that the assert was triggered because

/* static */ void BasePersistentStorageArray::SwitchMode(PersistentStorageMode mode, bool ignore_prev_mode)
was called twice in a row, both times trying to enter the game loop (PSM_ENTER_GAMELOOP).

@James103

This comment has been minimized.

Copy link
Contributor Author

@James103 James103 commented Aug 2, 2019

The game still crashes (Assertion failed at line 61 of d:\a\1\s\src\newgrf_storage.cpp: ignore_prev_mode || !gameloop) in 20190723-master-g2e686ad5d5 on dedicated server random mapgen failure. Crash files have been attached.

@James103

This comment has been minimized.

Copy link
Contributor Author

@James103 James103 commented Oct 23, 2019

Still crashes in 20191006-master-gdd11990ce0. Crash files have been attached.

Why haven't this been fixed already? It's basically a game loop logic problem.

@glx22

This comment has been minimized.

Copy link
Contributor

@glx22 glx22 commented Oct 26, 2019

 	[Code externe]	
>	openttd.exe!CustomAbort(int signal) Ligne 546	C++
 	openttd.exe!raise(int signum) Ligne 516	C++
 	openttd.exe!abort() Ligne 64	C++
 	openttd.exe!error(const char * s, ...) Ligne 129	C++
 	openttd.exe!BasePersistentStorageArray::SwitchMode(PersistentStorageMode mode, bool ignore_prev_mode) Ligne 101	C++
 	openttd.exe!StateGameLoop() Ligne 1385	C++
 	openttd.exe!GameLoop() Ligne 1478	C++
 	openttd.exe!VideoDriver_Dedicated::MainLoop() Ligne 304	C++
 	openttd.exe!openttd_main(int argc, char * * argv) Ligne 862	C++
 	openttd.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Ligne 444	C++
 	[Code externe]	
glx22 added a commit to glx22/OpenTTD that referenced this issue Oct 26, 2019
glx22 added a commit to glx22/OpenTTD that referenced this issue Nov 4, 2019
@LordAro LordAro closed this in ddffe32 Nov 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.