MantisBT - VCMI
View Issue Details
0003160VCMIMechanics - Battlespublic2020-12-13 07:582020-12-13 08:46
0003160: Crash on some battle actions
The bug is well reproducible, but it takes some time of gameplay to get to it. The bug is: If an experienced stack, that casts some magic before attack, attacks a weak stack, then it may be that this magic casting already kills the stack. Now if then after that magic the original attack takes place, this affects an already dead (aka no more existent) stack. This immediately crashes the game with a memory access violation.
This mostly happens with Gogs and Liches. F.ex. Gogs cast fireball before attacking. If that fireball already kills the stack, then the following original attack crashes the game.
I assume that a stack, that gets killed, is removed (the object is deleted). So the pointer to the object is now invalid. The subsequent attack uses this invalid pointer and so crashes the game.
Suggestion: When killing a stack, after deleting the object, set the pointer to NULL. And then before any action, check for NULL pointer, and if so, just do nothing.
It takes some time of gameplay to reproduce this. You need an experienced stack of Gogs or Liches. And preferably a big stack. Now take that big experienced stack and attack a weak stack (f.ex. a single level 1 creature). You see the pre-attack magic taking place and killing the stack. Then the subsequent attack crashes the game.
It is not possible to reproduce this bug with a fresh new map on day 1. To reproduce it you need a sufficiently experienced stack. You get easier to a sufficiently experienced stack on big maps.
This bug seems to not only happen in real battles with at least 1 human player. It seems it also happens in pure AI battles. At least the crash messages and the logs point to this.
No tags attached.
Issue History
2020-12-13 07:58SiegfriedNew Issue
2020-12-13 08:46misioklesNote Added: 0007961

2020-12-13 08:46   
I can confirm that sometimes it happens.