MantisBT - VCMI
View Issue Details
0002442VCMIMechanics - Battlespublic2016-05-16 16:082022-04-12 10:47
8cichy8 
AVS 
normalcrashsometimes
closedfixed 
pcdebianjessie
0.98g 
0.99 
0002442: crash after town battle
After town battle victory -> click on confirm button of battle summary dialog -> crash
Attack with hero Isra on castle which is before him. If you attack immediately, then it crash every time, but if you wait some day, or move somewhere and back, then it crash only sometimes. Probably doesn't happens with other hero.
Saved game is attached
No tags attached.
duplicate of 0002445closed AVS Crash after town battle victory 
related to 0002415closed SXX Crash on castle battle 
bz2 rand01_crash_after_castle_battle_save.tar.bz2 (823,826) 2016-05-16 16:08
https://bugs.vcmi.eu/file_download.php?file_id=2497&type=bug
png SiegeHelper.png (549,240) 2016-07-04 22:27
https://bugs.vcmi.eu/file_download.php?file_id=2501&type=bug
png

patch Gate-Fix.patch (1,045) 2016-07-04 23:01
https://bugs.vcmi.eu/file_download.php?file_id=2502&type=bug
Issue History
2016-05-16 16:088cichy8New Issue
2016-05-16 16:088cichy8File Added: rand01_crash_after_castle_battle_save.tar.bz2
2016-05-16 16:378cichy8Note Added: 0006512
2016-07-04 22:27rumianomFile Added: SiegeHelper.png
2016-07-04 22:28rumianomNote Added: 0006517
2016-07-04 23:01rumianomFile Added: Gate-Fix.patch
2016-07-04 23:02rumianomNote Added: 0006518
2016-07-05 13:08AVSRelationship addedduplicate of 0002445
2016-07-05 13:10AVSAssigned To => SXX
2016-07-05 13:10AVSStatusnew => assigned
2016-07-05 13:27AVSRelationship addedrelated to 0002415
2016-07-05 13:29AVSNote Added: 0006520
2016-07-05 13:29AVSAssigned ToSXX => AlexVinS
2016-07-05 13:29AVSStatusassigned => feedback
2016-07-05 13:29AVSAssigned ToAlexVinS => AVS
2016-07-05 13:29AVSStatusfeedback => assigned
2016-07-05 13:29AVSStatusassigned => feedback
2016-07-05 13:34AVSNote Edited: 0006520bug_revision_view_page.php?bugnote_id=6520#r3188
2016-07-05 19:53rumianomNote Added: 0006521
2016-07-05 20:02AVSNote Added: 0006522
2016-07-30 06:578cichy8Note Added: 0006535
2016-07-30 06:578cichy8Statusfeedback => assigned
2016-08-01 15:16AVSNote Added: 0006536
2016-08-01 15:30AVSNote Added: 0006537
2016-08-04 05:248cichy8Note Added: 0006538
2016-08-04 06:01AVSNote Added: 0006539
2016-08-04 06:02AVSStatusassigned => resolved
2016-08-04 06:02AVSFixed in Version => 0.99
2016-08-04 06:02AVSResolutionopen => fixed
2022-04-12 10:47PovelitelStatusresolved => closed

Notes
(0006512)
8cichy8   
2016-05-16 16:37   
update: also happens with other hero
(0006517)
rumianom   
2016-07-04 22:28   
the same issue as 0002445
and seems related to 0002415. I have attached Debugger screenshot.
(0006518)
rumianom   
2016-07-04 23:02   
I have attached a patch that fixes the issue for me. Could you have look?
(0006520)
AVS   
2016-07-05 13:29   
(edited on: 2016-07-05 13:34)
Unable to reproduce.

(0006521)
rumianom   
2016-07-05 19:53   
That's weird. I did a little bit more investigation and I could reproduce the crash each time.

My system details: Ubuntu 16.04 amd64, version tested is a build of the latest develop branch commit 21fff9d


It is related to the battle finishing before the confirmation of the result and destruction of CBattleInterface. In the logs I have multiple errors about trying to access battle that already finished. (I have added couple more log statements)
--------------------------------------------------------------
battle is now B=0x7fffb00457a0
battle is now B=0x7fffb00457a0
SiegeHelper called
Opening BattleAI
Loaded Battle AI
gateStateChangedoldState=1 state=3
gateStateChangedoldState=3 state=1
Warning: an orphaned child!
battleGetHeroInfo: side 1 does not have hero!
battle is now B=0
battle is now B=0
Warning: an orphaned child!
battleGetAllObstacles called when no battle!
battleGetStacksIf called when no battle!
battleGetAllObstacles called when no battle!
battleGetGateState called when no battle!
bExitf from Battle Result
battleGetAllObstacles called when no battle!
battleGetStacksIf called when no battle!
battleGetAllObstacles called when no battle!
battleGetGateState called when no battle!
battleGetStackByPos called when no battle!
~SiegeHelper called
battleGetGateState called when no battle!
read: Connection reset by peer
----------------------------------------------------------------

It looks like many things are trying to access battle that has already finished (Client.cpp::768::battleFinished has set battle to null) to derive the rendering state.

Maybe CBattleInterface should keep track of the state in it's own instance to be able to clean SDL surfaces?

AVS on which OS did you try to reproduce the bug?
(0006522)
AVS   
2016-07-05 20:02   
OS is different - win7 64, but in this case it should not matter.
(0006535)
8cichy8   
2016-07-30 06:57   
looks like your patch helped (doesn't crash - even though it still print errors)
thanks
(0006536)
AVS   
2016-08-01 15:16   
Which errors?
(0006537)
AVS   
2016-08-01 15:30   
patch applied in https://github.com/vcmi/vcmi/commit/6e24d1e929a902bb743b0cc4396f2f2d5e484a78/ [^]

thanks
(0006538)
8cichy8   
2016-08-04 05:24   
logs(red):

battleGetAllObstacles called when no battle!
battleGetStacksIf called when no battle!
battleGetAllObstacles called when no battle!
battleGetGateState called when no battle!
battleGetAllObstacles called when no battle!
battleGetStacksIf called when no battle!
battleGetAllObstacles called when no battle!
battleGetGateState called when no battle!
battleGetStackByPos called when no battle!
battleGetGateState called when no battle!
(0006539)
AVS   
2016-08-04 06:01   
"xxx called when no battle" is a known problem, mostly harmless but not easy fixable. Not related to this issue.