Heap Corruption and Corrupted Saves

Make all T-Engine/ToME 4 bug reports here

Moderator: Moderator

Post Reply
Message
Author
tesserekt
Posts: 4
Joined: Sun Jan 04, 2026 5:04 pm

Heap Corruption and Corrupted Saves

#1 Post by tesserekt »

Hello Fellow TOMErs

I recently got into this game and I have been running into relatively frequent crashes that are corrupting my saves. Most recently my game crashed when entering Derth for the first time. I entered the zone and the loading progress bar got to 100% and then just stayed there until the game eventually crashed.

I am on Windows 11 with an i9 and a 4070. I am playing the game on 1920x1080 Windowed. I am using the Steam version, unsure of the exact version at the moment. I have all the shaders turned off. My drivers are up to date. My Steam overlay is disabled.

From the te4_log.txt the game appears to start trying to save but then gets in a loop and eventually crashed

This is where the save starts

Code: Select all

Updating zone name	Derth
C Map minimap texture: 361 (50x50; 64x64)
[SAVEFILE PIPE] Already saving data	game	Smashing!	waiting for finish before piping...
[SAVEFILE PIPE] force waiting
Make wait background texture 560 : 0x1084096512 (0, 1083275264)
[SAVEFILE PIPE] Resaving sent	Smashing!	game	/save/smashing_/game.teag.tmp
Saving zipname /save/smashing_/game.teag.tmp
Saved zipname /save/smashing_/game.teag.tmp
[SAVEFILE PIPE] Checking save	Smashing!	game	/save/smashing_/game.teag.tmp
Loading savefile 	/save/smashing_/
[SAVEFILE] checked validity of type	game	 => path not found
[SAVEFILE] path info	/save/smashing_/game.teag	=>	nil
[SAVEFILE PIPE] *RE*new save running in the pipe:	Smashing!	game	::	game.teag	::	table: 0x21464ec0	=>	table: 0x1f892a38	(9315)
Loading savefile 	/save/smashing_/
[SAVEFILE PIPE] Resaving sent	Smashing!	game	/save/smashing_/game.teag.tmpSaving zipname /save/smashing_/game.teag.tmp

Saved zipname /save/smashing_/game.teag.tmp
[SAVEFILE PIPE] Checking save	Smashing!	game	/save/smashing_/game.teag.tmp
Loading savefile 	/save/smashing_/
[SAVEFILE] checked validity of type	game	 => path not found
[SAVEFILE] path info	/save/smashing_/game.teag	=>	nil
[SAVEFILE PIPE] *RE*new save running in the pipe:	Smashing!	game	::	game.teag	::	table: 0x21464ec0	=>	table: 0x1f892a38	(9315)
Then after about 2,000 lines of those messages repeating the log terminates in the following. Yes, it was cut off mid-line by the looks of it

Code: Select all

Loading savefile 	/save/smashing_/
[SAVEFILE] checked validity of type	game	 => path not found
[SAVEFILE] path info	/save/smashing_/game.teag	=>	nil
[SAVEFILE PIPE] *RE*new save running in the pipe:	Smashing!	game	::	game.teag	::	table: 0x21464ec0	=>	table: 0x1f892a38	(9315)
Loading savefile 	/save/smashing_/
[SAVEFILE PIPE] Resaving sent	Smashing!	game	/save/smashing_/game.teag.tmp
Saving zipname /save/smashing_/game.teag.tmp
Saved zipname /save/smashing_/game.teag.tmp
[SAVEFILE PIPE] Checking save	Smashing!	game	/save/smashing_/game.teag.tmp
Loading savefile 	/save/smashing_/
[SAVEFILE] checked validity of type	game	 => path not found
[SAVEFILE] path info	/save/smashing_/game.teag	=>	nil
[SAVEFILE PIPE] *RE*new save running in the pipe:	Smashing!	game	::	game.teag	::	table: 0x21464ec0	=>	table: 0x1f892a38	(9315)
Loading savefile 	/save/smashing_/
[SAVE
I checked the Windows event viewer and saw the following. From my understanding this is a crash from Heap corruption.

Code: Select all

Faulting application name: t-engine.exe, version: 1.0.0.0, time stamp: 0x609c5e43 
Faulting module name: ntdll.dll, version: 10.0.26100.7462, time stamp: 0x20848390 
Exception code: 0xc0000374 
Fault offset: 0x000fc61f 
Faulting process id: 0x81F4 
Faulting application start time: 0x1DC7D8E1003033E 
Faulting application path: C:\Steam\steamapps\common\TalesMajEyal\t-engine.exe Faulting module path: C:\WINDOWS\SYSTEM32\ntdll.dll 
Report Id: ccaa9d73-092a-4dd9-a654-b3762183f9ca 
Faulting package full name: 
Faulting package-relative application ID:
After the crash the save is unable to be continued. The save file is replaced with the temporary, game.teag.tmp. Dropping the .tmp extension does not work for forcing the game to load, though I have not tried it on this exact save asI wanted to preserve the logs for reporting.

Does anyone else encounter this crash on Windows 11? Are others playing on Windows 11 or are you on a different OS?

I have a workaround to backup my local saves but sometimes I forget and will lose more progress can my little old heart can bear.

AstralWanderer
Higher
Posts: 75
Joined: Tue Oct 22, 2019 5:54 pm

Re: Heap Corruption and Corrupted Saves

#2 Post by AstralWanderer »

Welcome to the forums, Tesserekt.

If you've not already done so, take a look at the Help! My Saves keep not working thread - there are several options offered there which might help with your situation here.

tesserekt
Posts: 4
Joined: Sun Jan 04, 2026 5:04 pm

Re: Heap Corruption and Corrupted Saves

#3 Post by tesserekt »

Thanks. I had browsed through that thread before. I had tried to drop the tmp from my broken save and thinking back I did see some lua errors when that file failed to load. Perhaps that save could be fixed but I was playing on Roguelike and not that concerned about fixing the save file.

I am more interested in figuring out why the game keeps crashing on my machine. My latest theory is that it is being caused by running on a laptop with 2 GPUs and the default setting for TOME was to "Let Windows decide" which GPU to use. I experienced some odd graphical behavior when selecting "New Game" which seemed GPU related. The game would be in fullscreen, I press New Game, then the game loses focus and then goes full screen again, sometimes several times. I have since specified for TOME to only use the high powered GPU but I have not gotten around to testing it yet because . . .

I have another computer which is a tower (only 1 GPU) that is still on Windows 10. I managed to play quite a bit on that machine without crashing or experiencing any graphical oddities. I am unsure if the crashes I am encountering are Windows 11 or dual-GPU laptop issues. For now I can play the game on my tower but I would love to know if upgrading to Windows 11 would cause the game to crash on my tower as well.

AstralWanderer
Higher
Posts: 75
Joined: Tue Oct 22, 2019 5:54 pm

Re: Heap Corruption and Corrupted Saves

#4 Post by AstralWanderer »

Given the log files above show issues occurring with game saves, experimenting with the save options available (disabling background saves and disabling online functions) might be worth doing. Also look out for anything running on your system that might be accessing savegame files (e.g. anti-virus scanners, cloud synchronisation tools) - the linked thread mentions using Process Monitor to check for this.

In terms of graphics, TOME is pretty undemanding (I've run it on a 2011 laptop with an ATI Radeon Xpress 200M GPU) so you should be able to use either GPU on your system.

tesserekt
Posts: 4
Joined: Sun Jan 04, 2026 5:04 pm

Re: Heap Corruption and Corrupted Saves

#5 Post by tesserekt »

The root cause of this is rather mundane. There is a flaw in the logic of the save process that if the rename of the temp save `game.teag.tmp` to `game.teag` in the C code it is just treated as if it succeeded. It then reports back to the LUA code that the save worked. The LUA code will then attempt to validate the new `game.teag` (which does not exist because the rename failed) which will fail validation triggering another save attempt. This happens infinitely until you get that yellow dotted line crossing your screen and the game crashes, likely corrupting your save because it was trying to save a new `game.teag.tmp` failing in process.

I have a LUA patch which prevents the crash and save corruption. When checking the validity of the save file if the `game.teag` is not present it will validate if `game.teag.tmp` is there and consider that good enough. Subsequent saves all still fail to rename but a new `game.teag.tmp` is cut each time. Your progress is continually saved to the `game.teag.tmp`. The minor issue (albeit better than corrupting your save) is that after exiting the game you still only have `game.teag.tmp` so you cannot load back into it yet through the games menu. You need to manually drop the `.tmp` extension (in effect doing the rename the engine failed to do) and the voila you can load your save.

I am currently putting off actually fixing this because I just do not want to install Visual Studio or C build tools on my leisure machine. The fix could be done in many ways and I have not decided on the best approach so instead I will layout the issue. In `serial.c` the function `finish_zip` handles the deletion, save and rename. This is where the flaw lives. There is 0 error handling and 0 examining of the results of any of the actions taken. Meaning that if they fail the engine does not care and just chugs along erroneously reporting to the LUA that it worked. The very first step is to delete your save file which usually works. Then it attempts to rename the file which some times fails (at least on Windows 11 currently) then it tells the the LUA code where it can find the now-deleted, never replaced `game.teag`. This function needs to be fault tolerant and at least know when it failed so it doesn't trigger an upstream infinite loop.

Why does the rename fail? I do not know because the engine doesn't even know that it happened and reports nothing back. It is possible this is some Windows 11 quirk but it can be coded against defenisvely so it doesn't hang the engine and corrupt your save.

tesserekt
Posts: 4
Joined: Sun Jan 04, 2026 5:04 pm

Re: Heap Corruption and Corrupted Saves

#6 Post by tesserekt »

The rename fails because Windows says `game.teag.tmp` is open in Tales of MajEyal. When the game is unable to rename the file I was also unable to rename the file manually. Closing the game allowed me to rename the file.

Post Reply