MantisBT - VCMI
View Issue Details
0003033VCMIAI - Adventure Mappublic2019-02-10 17:432022-03-22 17:45
mpech 
Dydzio 
normalmajoralways
assignedopen 
Ubuntu 16.04.5 LTS
0.99 
 
0003033: VisitObj construction with invalid instance id
hi guys,

got a core

    #0 0x00007f014727e46f in CGObjectInstance::visitablePos (this=0x0) at /home/mpech2/dl/vcmi/lib/mapObjects/CObjectHandler.cpp:336
    336 return pos - getVisitableOffset();
    [Current thread is 1 (Thread 0x7f0110ddf700 (LWP 27620))]
    (gdb) bt
    #0 0x00007f014727e46f in CGObjectInstance::visitablePos (this=0x0) at /home/mpech2/dl/vcmi/lib/mapObjects/CObjectHandler.cpp:336
    #1 0x00007f011130b43c in Goals::VisitObj::VisitObj (this=0x7f0110ddd850, Objid=3879) at /home/mpech2/dl/vcmi/AI/VCAI/Goals/VisitObj.cpp:96
    0000002 0x00007f01112f9743 in Goals::Win::whatToDoToAchieve (this=0x7f010213ce00) at /home/mpech2/dl/vcmi/AI/VCAI/Goals/Win.cpp:70
    0000003 0x00007f01113441ad in VCAI::decomposeGoal (this=0x7f0102354d60, ultimateGoal=...) at /home/mpech2/dl/vcmi/AI/VCAI/VCAI.cpp:2416
    0000004 0x00007f0111335f99 in VCAI::mainLoop (this=0x7f0102354d60) at /home/mpech2/dl/vcmi/AI/VCAI/VCAI.cpp:878
    0000005 0x00007f011133537c in VCAI::makeTurn (this=0x7f0102354d60) at /home/mpech2/dl/vcmi/AI/VCAI/VCAI.cpp:806
    0000006 0x00007f01113e8c45 in boost::_mfi::mf0<void, VCAI>::operator() (this=0x7f00fc261d08, p=0x7f0102354d60)
        at /usr/include/boost/bind/mem_fn_template.hpp:49
    0000007 0x00007f01113e8ba8 in boost::_bi::list1<boost::_bi::value<VCAI*> >::operator()<boost::_mfi::mf0<void, VCAI>, boost::_bi::list0> (
        this=0x7f00fc261d18, f=..., a=...) at /usr/include/boost/bind/bind.hpp:253
    0000008 0x00007f01113e86e4 in boost::_bi::bind_t<void, boost::_mfi::mf0<void, VCAI>, boost::_bi::list1<boost::_bi::value<VCAI*> > >::operator() (
        this=0x7f00fc261d08) at /usr/include/boost/bind/bind.hpp:893
    0000009 0x00007f01113e7dc4 in boost::detail::thread_data<boost::_bi::bind_t<void, boost::_mfi::mf0<void, VCAI>, boost::_bi::list1<boost::_bi::value<VCAI*> > > >::run (this=0x7f00fc261b50) at /usr/include/boost/thread/detail/thread.hpp:116
    0000010 0x00007f01460095d5 in ?? () from /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.58.0
    0000011 0x00007f0145ddf6ba in start_thread (arg=0x7f0110ddf700) at pthread_create.c:333
    0000012 0x00007f014297f41d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

also got some console.log

    Cannot get object with id 3879. Object was removed

load map.
as red, just end your turn. will crash when orange player plays
I tried below diff (taking exemple from fulfillsMe) just so that I can continue playing..
It seems orange player can then kill Solmyr and end the game.
I think there is another slight bug since victory is announced to be red although orange it is orange who fulfilled conditions victory (but purpose of this ticket is rather the crash)

--- a/AI/VCAI/Goals/VisitObj.cpp
+++ b/AI/VCAI/Goals/VisitObj.cpp
@@ -93,7 +93,10 @@ TSubgoal VisitObj::whatToDoToAchieve()
 VisitObj::VisitObj(int Objid) : CGoal(VISIT_OBJ)
 {
        objid = Objid;
- tile = ai->myCb->getObjInstance(ObjectInstanceID(objid))->visitablePos();
+ auto obj = ai->myCb->getObjInstance(ObjectInstanceID(objid));
+ if(obj){
+ tile = obj->visitablePos();
+ }
        priority = 3;
 }
 
R1
zip sat.zip (1,399,210) 2019-02-10 17:43
https://bugs.vcmi.eu/file_download.php?file_id=2981&type=bug
Issue History
2019-02-10 17:43mpechNew Issue
2019-02-10 17:43mpechFile Added: sat.zip
2019-02-10 18:13AVSNote Added: 0007748
2019-02-10 18:13AVSAssigned To => Dydzio
2019-02-10 18:13AVSSeveritycrash => major
2019-02-10 18:13AVSStatusnew => assigned
2019-02-10 18:13AVSSummaryCrash in visitablePos => VisitObj construction with invalid instance id
2022-03-22 17:45PovelitelTag Attached: R1

Notes
(0007748)
AVS   
2019-02-10 18:13   
Patch fixing crash case applied in https://github.com/vcmi/vcmi/commit/1f83953da4130af2d4c33303ae462bda396185df, [^] thanks. Bug itself to be fixed, there are some issues with goal decomposition being discussed recently.