MantisBT - VCMI
View Issue Details
0001259VCMIMechanics - Adventure Mappublic2013-04-24 05:312013-08-18 21:04
Warmonger 
Tow 
normalcrashsometimes
closedfixed 
 
0.93 
0001259: AI crashes when trying to find visitable offset
After recent changes which removed other bugs, now I get only one bug during long AI runs. Debugger claims access violation in this function:

int3 CGObjectInstance::getVisitableOffset() const
{
    for(int y = 0; y < 6; y++)
        for (int x = 0; x < 8; x++)
            if((defInfo->visitMap[5-y] >> x) & 1)
                return int3(x,y,0);

    logGlobal->warnStream() << "Warning: getVisitableOffset called on non-visitable obj!";
    return int3(-1,-1,-1);
}

Looks like visitMap size is innapriopriate. It happens on any of random tests maps I used so far, so no new objects (towns, dwellings) should be present.
No tags attached.
related to 0001391closed Tow Failed to create savegame after ~2 months of gameplay. 
child of 0001409closed Tow Crashes during AI turn (accessing removed objects) 
rar 1259dump.rar (2,107,870) 2013-04-26 11:18
https://bugs.vcmi.eu/file_download.php?file_id=1262&type=bug
Issue History
2013-04-24 05:31WarmongerNew Issue
2013-04-24 05:43WarmongerDescription Updatedbug_revision_view_page.php?rev_id=2177#r2177
2013-04-24 10:13IvanNote Added: 0003519
2013-04-24 11:17TowNote Added: 0003520
2013-04-24 11:24WarmongerNote Added: 0003521
2013-04-24 11:31TowNote Added: 0003522
2013-04-26 04:22WarmongerNote Added: 0003529
2013-04-26 06:26WarmongerNote Edited: 0003529bug_revision_view_page.php?bugnote_id=3529#r2181
2013-04-26 11:18WarmongerNote Added: 0003530
2013-04-26 11:18WarmongerFile Added: 1259dump.rar
2013-04-26 11:18WarmongerNote Edited: 0003530bug_revision_view_page.php?bugnote_id=3530#r2183
2013-08-01 14:49WarmongerRelationship addedrelated to 0001391
2013-08-15 16:00TowNote Added: 0003850
2013-08-15 16:00TowRelationship addedchild of 0001409
2013-08-18 21:04TowNote Added: 0003874
2013-08-18 21:04TowStatusnew => closed
2013-08-18 21:04TowAssigned To => Tow
2013-08-18 21:04TowResolutionopen => fixed

Notes
(0003519)
Ivan   
2013-04-24 10:13   
Is there a chance that whole defInfo is missing (e.g. null or broken pointer)? IIRC visitMap is C-style array so it have constant size.
(0003520)
Tow   
2013-04-24 11:17   
I'd rather guess it is object pointer (this) that is likely to be null. If you encounter this again, please save the full stacktrace and logs.

I'm also working on serializing AI state in saves, that should make reproducing such bugs much easier.
(0003521)
Warmonger   
2013-04-24 11:24   
Looks like it.

Of all 1 destinations, object oid=16843009 seems nice
Disaster happened.
Reason: 0xc0000005 - EXCEPTION_ACCESS_VIOLATION at 0023:629
Attempt to read from 0x00000038
Thread ID: 4744 [4744]
Crash info will be put in VCMI_client.exe_crashinfo.dmp

This happened also when I turned all the new towns off. Will investigate later.
(0003522)
Tow   
2013-04-24 11:31   
Please show me the full log. It is possible, that object 16843009 was already removed.
[side noteā€¦ awfully high number, is that reasonable object id at all?]
(0003529)
Warmonger   
2013-04-26 04:22   
(edited on: 2013-04-26 06:26)
Of course id was completely wrong. Even biggest map has no more than 127k tiles.

I tried to reproduce it with r3358 and new build using MVS2012 with Boost 1.53, but failed. AI continued playing for like 78 months over night ;)

(0003530)
Warmonger   
2013-04-26 11:18   
Happened again. Object seems to be NULL.

Stack trace:

     VCMI_lib.dll!CGObjectInstance::getVisitableOffset() Line 493 C++
     VCMI_lib.dll!CGObjectInstance::visitablePos() Line 554 C++
     VCAI.dll!VCAI::goVisitObj(const CGObjectInstance * obj, HeroPtr h) Line 1064 C++
> VCAI.dll!VCAI::wander(HeroPtr h) Line 1511 C++
     VCAI.dll!VCAI::performTypicalActions() Line 2337 C++
     VCAI.dll!VCAI::tryRealize(CGoal g) Line 1963 C++
     VCAI.dll!VCAI::striveToGoal(const CGoal & ultimateGoal) Line 2102 C++
     VCAI.dll!VCAI::makeTurnInternal() Line 1046 C++
     VCAI.dll!VCAI::makeTurn() Line 985 C++
     VCAI.dll!boost::`anonymous namespace'::thread_start_function(void *) C++
     msvcr110.dll!_callthreadstartex() Line 354 C
     msvcr110.dll!_threadstartex(void * ptd) Line 332 C
     kernel32.dll!74e333aa() Unknown
     [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
     ntdll.dll!76fe9ef2() Unknown
     ntdll.dll!76fe9ec5() Unknown

Attaching everything possible.

(0003850)
Tow   
2013-08-15 16:00   
All such issues now go under 0001409 and should be fixed soon.
(0003874)
Tow   
2013-08-18 21:04   
Covered by 0001409 and fixed in r3501.