Home » MODDING HQ 1.13 » v1.13 Bug Reports » Crash after longer playing sessions + possible fix
Crash after longer playing sessions + possible fix[message #345261] Mon, 02 May 2016 19:00 Go to next message
Subotai

Messages:2
Registered:May 2016
Hi!

I found and tested the following in an older (ancient big grin) version of the 1.13 mod, but I think it's still a problem. ( Unfortunately I couldn't compile the fix with the latest version, but looking at the code, it's still looks the same to me, and the crash happens with JA2_Stable2014_r7798 too.)

So the bug is that, after playing for a longer period of time the game GUI messes up and crashes ( with this assert in debug mode, or in JA2_Stable2014_r7798):

Assertion Failure [Line 1944 in file Button System.cpp]. Attempting to do a debug save as SaveGame247.sav (this may fail)
"Attempting to QuickCreateButton with out of range ImageID -1."


To reproduce this bug I saved the game in tactical mode, with one of my merc's inventory panel open, and continuously quick-loaded the game. The crash always seemed to happen after reloading the game about 70 times.

I found that the problem is simply that,( I'm not a coder so my theory needs confirmation), when the game loads buttons in Interface Panels.cpp:
BOOLEAN CreateSMPanelButtons( )
the
...
iBurstButtonImages[ WM_AUTOFIRE ]    = UseLoadedButtonImage( iSMPanelImages[ STANCEUP_IMAGES	], -1, 17, -1, -1, -1 );
...
button is loaded, but not removed like all the other buttons in:
void	RemoveSMPanelButtons( )
later in the code.
So every time the game loads buttons (switch between strategic/tactical interface, reloading game etc...) it has to reserve more and more image slots to the buttons, because the slot of the WM_AUTOFIRE button hasn't been cleared. This leads to an assert here in Button System.cpp:
INT32 QuickCreateButton (UINT32 Image,...)
...
if( Image < 0 || Image >= MAX_BUTTON_PICS )
{
	sprintf( str, "Attempting to QuickCreateButton with out of range ImageID %d.", Image );
	AssertMsg( 0, str );
}
...
I observed the maximum of "Image" slot count growing every time I reloaded ( every time around 70 times to reproduce the bug big grin ) or switched between GUI layers, until it reached 256 (MAX_BUTTON_PICS) then it jumped up to 4294967295 ( 4gb ? possibly a memory leak related consequence, i haven't dug deeper, that's way beyond my knowledge big grin) , the GUI messed up and when i tried to switch to strategic map it crashed.

So long story short i added:
UnloadButtonImage( iBurstButtonImages[ WM_AUTOFIRE ] );

and it seems to be fixed for me now. The "Image" count is jumping between the same numbers every time I reload now, the maximum is not increasing ( I assume every button is created and dumped properly now), the game doesn't crash or assert.

Sorry for the long, and awkward explanation and wall of text, I'm not a coder at all, nor familiar with programming besides tinkering with the JA2 code big grin , and as I said, couldn't test with a newer version, and don't know if this problem was solved already in an other way or not.
Re: Crash after longer playing sessions + possible fix[message #345262 is a reply to message #345261] Mon, 02 May 2016 19:58 Go to previous messageGo to next message
RoWa21

 
Messages:2029
Registered:October 2005
Location: Austria
Thanks for the fix. Where exactly in the code (which method) did you add the line?
Please post a few lines of code before and after your line so I can figure out where to put the new line. Thanks.


Re: Crash after longer playing sessions + possible fix[message #345263 is a reply to message #345262] Mon, 02 May 2016 20:50 Go to previous messageGo to next message
Subotai

Messages:2
Registered:May 2016
It was simply missing from the bottom of RemoveSMPanelButtons( ) function here: (in Interface Panels.cpp) :

Toggle Spoiler


10 burst button image were loading every time in CreateSMPanelButtons( ), but only 9 of them were removed later.

I'm glad I could help if it works.

[Updated on: Mon, 02 May 2016 21:01]

Re: Crash after longer playing sessions + possible fix[message #345281 is a reply to message #345263] Tue, 03 May 2016 22:23 Go to previous message
RoWa21

 
Messages:2029
Registered:October 2005
Location: Austria
Good catch Subotai, the fix is committed.


Previous Topic: r8156 - kind of ghost jeep
Next Topic: case-sensitiv stuff (linux related)
Goto Forum:
  


Current Time: Sat Jul 20 23:07:41 EEST 2019

Total time taken to generate the page: 0.00817 seconds