Anonymous Login
2018-12-16 10:54 UTC

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000787OpenClonkEngine - GUIpublic2017-08-20 11:38
ReporterIsilkor 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusacknowledgedResolutionopen 
PlatformOSWin32OS Version
Product Version 
Target Version9.0Fixed in Version 
Summary0000787: Closing the window while in C4Startup init code accesses invalid memory
DescriptionClosing the game window sends a WM_CLOSE message, the handler of which unloads C4Startup. This breaks the initialization code of C4StartupGraphics because it does not check whether its instance is still valid.
Steps To Reproduce1. Start OpenClonk in windowed mode
2. With the progress bar higher than 38%, press Alt+F4
3. OpenClonk crashes with an access violation.
TagsNo tags attached.
Attached Files

-Relationships
+Relationships

-Notes

~0002835

Newton (administrator)

Hm I can reproduce this but I do not understand what is the issue with the code. Is the deconstructor (tried to be) called twice? If yes, seeing the second call in the stacktrace, when was the first call?

Also, if this comes down to having to ensure on every call of pInstance that pInstance is still there, the better solution would be to delay the unloading on receiving the WM_CLOSE message until everything was loaded so that there is only one path of execution we have to make sure works.

~0002838

Isilkor (developer)

A better solution would in my opinion be to save the important stuff (maybe config and any loaded players) when WM_CLOSE hits, and then just exit(0) without calling dtors. That way we'd also avoid having to do any deinitialization, which is superfluous anyway because we're exiting the process immediately after.

~0002842

Newton (administrator)

What needs to be saved when the game is closed on startup?

Also, I thought that config & loaded players are saved right when I selected it in the options / player selection(?)

~0002843

Isilkor (developer)

> What needs to be saved when the game is closed on startup?
Well, I want to avoid writing a special case for "WM_CLOSE during startup" and just do a quick teardown for all WM_CLOSE messages.
> Also, I thought that config & loaded players are saved right when I selected it in the options / player selection(?)
Might be, but it's certainly also saved when the application quits: https://git.openclonk.org/openclonk.git/blob/ac4ac045581f4ec8ffd763f973bff1ca02f00041:/src/game/C4Application.cpp#l596

~0002844

Newton (administrator)

Yes, I really wonder why. Looking into the source, the config is saved:

+ On startup (to fill in default config on first start after install or fix corrupted config)
+ On pressing [OK] after resolution change
+ On closing the option dialogue
+ On exit of the program

I propose this solution for the config saving:

+ remove config save on exit of program
+ add config save on end of a round (because in a round, the player can change the config)
+Notes

-Issue History
Date Modified Username Field Change
2012-05-28 14:45 Isilkor New Issue
2013-12-17 16:55 Newton Note Added: 0002835
2013-12-17 16:56 Newton Status new => acknowledged
2013-12-18 11:59 Isilkor Note Added: 0002838
2013-12-20 11:26 Newton Note Added: 0002842
2013-12-20 15:24 Isilkor Note Added: 0002843
2013-12-21 05:02 Newton Note Added: 0002844
2015-10-16 00:33 Sven2 Target Version => 7.0
2016-01-02 19:43 Clonkonaut Severity major => minor
2016-01-02 19:43 Clonkonaut Target Version 7.0 => 8.0
2017-08-20 11:38 Zapper Target Version 8.0 => 9.0
+Issue History