MantisBT - VCMI
View Issue Details
0002127VCMIMechanics - Adventure Mappublic2015-03-10 18:332022-04-12 11:04
Warmonger 
SXX 
normalcrashsometimes
closedfixed 
 
0.99 
0002127: Possible crash when hero is hired in town that gives him primary skill bonus
Debugger shows line
sps.id = hero->id;
In CGameHandler::changePrimSkill
When hero is recruited at town Marshchoke (Fortress)

Apparently hero pointer is not always correctly initialized at this point, or there are race conditions.
No tags attached.
related to 0002277closed SXX Random heroes always have subID of zero and don't inherit predefined options 
Issue History
2015-03-10 18:33WarmongerNew Issue
2015-03-10 18:42WarmongerSummaryPossible crash when hero is hired in town that givves him primary skill bonus => Possible crash when hero is hired in town that gives him primary skill bonus
2016-09-17 23:28SXXNote Added: 0006679
2016-09-17 23:29SXXNote Edited: 0006679bug_revision_view_page.php?bugnote_id=6679#r3237
2016-09-18 01:04SXXNote Added: 0006680
2016-09-18 01:04SXXAssigned To => SXX
2016-09-18 01:04SXXStatusnew => assigned
2016-09-18 01:39SXXRelationship addedrelated to 0002277
2016-09-18 01:40SXXNote Added: 0006681
2016-09-18 07:08SXXNote Added: 0006683
2016-09-18 07:08SXXStatusassigned => resolved
2016-09-18 07:08SXXFixed in Version => 0.99
2016-09-18 07:08SXXResolutionopen => fixed
2022-04-12 11:04PovelitelStatusresolved => closed

Notes
(0006679)
SXX   
2016-09-17 23:28   
(edited on: 2016-09-17 23:29)
I got exactly same reproducible crash, but in GiveBonus::applyGs.
Object simply not exist in GS when package applied.

Investigating for fix...

(0006680)
SXX   
2016-09-18 01:04   
So reason is:

- In CGameHandler::hireHero there one hero choosen from PlayerState::availableHeroes to "nh" ptr.
- Then in HeroRecruited::applyGs it's choosen from heroesPool[hid].
- After HeroRecruited applied in GH "nh" passed to other functions such as vistiCastleObjects.

Problem occur because for whatever reason heroesPool contain wrong hero there.
So while GS initialized different hero GH attempt to use hero that not on map and other netpacks fail since there is no such hero on map.
(0006681)
SXX   
2016-09-18 01:40   
This one might be related to 0002277 in case it's didn't fixed everything perfectly.
Though at least random heroes have proper subID so bug might be somewhere else.
(0006683)
SXX   
2016-09-18 07:08   
Fixed:
https://github.com/vcmi/vcmi/commit/635c48f889d8d642ac1fb7517222356498bd0953 [^]

More info available in 0002277.