OpenXcom Bug Tracker
star_faded.png
Please log in to bookmark issues
bug_report_small.png
CLOSED  Bug report #819  -  Battlescape abort with vector::_M_range_check
Posted Sep 07, 2014 - updated Apr 11, 2019
icon_info.png This issue has been closed with status "Not a bug" and resolution "NOT AN ISSUE".
Issue details
  • Type of issue
    Bug report
  • Status
     
    Not a bug
  • Assigned to
    Not assigned to anyone
  • Progress
       
  • Type of bug
    Not triaged
  • Likelihood
    Not triaged
  • Effect
    Not triaged
  • Posted by
     Myk
  • Owned by
    Not owned by anyone
  • Category
    Not determined
  • Resolution
    NOT AN ISSUE
  • Priority
    Not determined
  • Reproducability
    Not determined
  • Severity
    Not determined
  • Nightly / Git version
    icon_customdatatype.png 82fd98479b19037196745397286014cc84b55666
  • Platform
    icon_customdatatype.png Gentoo Linux
  • Master Game
    icon_customdatatype.png Not determined
  • Mods
    icon_customdatatype.png Not determined
Issue description
This is the 30th mission or so that I've played in this runthough, but this particular mission causes OpenXcom to abort during the alien's first turn.

I built a version with debug on and ran it in gdb to get the backtrace and some info on the offending vector (the element at index 257 was requested from a vector with only 253 items):
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check
 
Program received signal SIGABRT, Aborted.
0x00007ffff616dbf5 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56      ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007ffff616dbf5 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007ffff616f067 in __GI_abort () at abort.c:89
#2  0x00007ffff6a61e05 in __gnu_cxx::__verbose_terminate_handler () at /tmp/portage/sys-devel/gcc-4.7.3-r1/work/gcc-4.7.3/libstdc++-v3/libsupc++/vterminate.cc:95
#3  0x00007ffff6a5fec6 in __cxxabiv1::__terminate (handler=<optimized out>) at /tmp/portage/sys-devel/gcc-4.7.3-r1/work/gcc-4.7.3/libstdc++-v3/libsupc++/eh_terminate.cc:40
#4  0x00007ffff6a5fef3 in std::terminate () at /tmp/portage/sys-devel/gcc-4.7.3-r1/work/gcc-4.7.3/libstdc++-v3/libsupc++/eh_terminate.cc:50
#5  0x00007ffff6a6017e in __cxxabiv1::__cxa_throw (obj=0x6003920, tinfo=<optimized out>, dest=<optimized out>) at /tmp/portage/sys-devel/gcc-4.7.3-r1/work/gcc-4.7.3/libstdc++-v3/libsupc++/eh_throw.cc:83
#6  0x00007ffff6ab2d9d in std::__throw_out_of_range (__s=0xa04836 "vector::_M_range_check") at /tmp/portage/sys-devel/gcc-4.7.3-r1/work/gcc-4.7.3/libstdc++-v3/src/c++11/functexcept.cc:82
#7  0x0000000000739eb9 in std::vector<OpenXcom::Node*, std::allocator<OpenXcom::Node*> >::_M_range_check (this=0x60933c8, __n=257) at /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/include/g++-v4/bits/stl_vector.h:774
#8  0x0000000000738e57 in std::vector<OpenXcom::Node*, std::allocator<OpenXcom::Node*> >::at (this=0x60933c8, __n=257) at /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/include/g++-v4/bits/stl_vector.h:792
#9  0x000000000098d13a in OpenXcom::SavedBattleGame::getPatrolNode (this=0x6093380, scout=false, unit=0x65d15e0, fromNode=0x65c0e00) at /home/myk/src/openxcom/src/Savegame/SavedBattleGame.cpp:1158
#10 0x000000000072f91d in OpenXcom::AlienBAIState::setupPatrol (this=0x65d1ee0) at /home/myk/src/openxcom/src/Battlescape/AlienBAIState.cpp:541
#11 0x000000000072e515 in OpenXcom::AlienBAIState::think (this=0x65d1ee0, action=0x7fffffffcce0) at /home/myk/src/openxcom/src/Battlescape/AlienBAIState.cpp:230
#12 0x000000000099b468 in OpenXcom::BattleUnit::think (this=0x65d15e0, action=0x7fffffffcce0) at /home/myk/src/openxcom/src/Savegame/BattleUnit.cpp:1593
#13 0x0000000000771e7c in OpenXcom::BattlescapeGame::handleAI (this=0x5183310, unit=0x65d15e0) at /home/myk/src/openxcom/src/Battlescape/BattlescapeGame.cpp:233
#14 0x0000000000771875 in OpenXcom::BattlescapeGame::think (this=0x5183310) at /home/myk/src/openxcom/src/Battlescape/BattlescapeGame.cpp:115
#15 0x00000000006ef56a in OpenXcom::BattlescapeState::think (this=0x525a220) at /home/myk/src/openxcom/src/Battlescape/BattlescapeState.cpp:565
#16 0x000000000078f914 in OpenXcom::Game::run (this=0x4e164d0) at /home/myk/src/openxcom/src/Engine/Game.cpp:268
#17 0x0000000000655ade in main (argc=3, argv=0x7fffffffd798) at /home/myk/src/openxcom/src/main.cpp:68
(gdb) frame 7
#7  0x0000000000739eb9 in std::vector<OpenXcom::Node*, std::allocator<OpenXcom::Node*> >::_M_range_check (this=0x60933c8, __n=257) at /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/include/g++-v4/bits/stl_vector.h:774
774               __throw_out_of_range(__N("vector::_M_range_check"));
(gdb) l
769           /// Safety check used only from at().
770           void
771           _M_range_check(size_type __n) const
772           {
773             if (__n >= this->size())
774               __throw_out_of_range(__N("vector::_M_range_check"));
775           }
776
777         public:
778           /**
(gdb) print size()
$1 = 253
(gdb) frame 9
#9  0x000000000098d13a in OpenXcom::SavedBattleGame::getPatrolNode (this=0x6093380, scout=false, unit=0x65d15e0, fromNode=0x65c0e00) at /home/myk/src/openxcom/src/Savegame/SavedBattleGame.cpp:1158
1158                    Node *n = getNodes()->at(scout ? i : fromNode->getNodeLinks()->at(i));
(gdb) l
1153
1154            for (int i = 0; i < end; ++i)
1155            {
1156                    if (!scout && fromNode->getNodeLinks()->at(i) < 1) continue;
1157
1158                    Node *n = getNodes()->at(scout ? i : fromNode->getNodeLinks()->at(i));
1159                    if ((n->getFlags() > 0 || n->getRank() > 0 || scout)                                                                                    // for non-scouts we find a node with a desirability above 0
1160                            && (!(n->getType() & Node::TYPE_SMALL) || unit->getArmor()->getSize() == 1)                                     // the small unit bit is not set or the unit is small
1161                            && (!(n->getType() & Node::TYPE_FLYING) || unit->getArmor()->getMovementType() == MT_FLY)       // the flying unit bit is not set or the unit can fly
1162                            && !n->isAllocated()                                                                                                                                            // check if not allocated
(gdb) print i
$4 = 3
(gdb) print scout
$5 = false
(gdb) print fromNode->getNodeLinks()->at(i)
$6 = (int &) @0x65c0e5c: 257
(gdb) print *fromNode->getNodeLinks()
$10 = std::vector of length 5, capacity 5 = {239, 230, -1, 257, 245}
Steps to reproduce this issue
- install Final Mod Pack 0.9.2 - load attached save - hit end turn

#2
Comment posted by
 Myk
Sep 07, 06:21
A file was uploaded. savegame that exhibits issueicon_open_new.png This comment was attached:

hit end turn to show issue
#5
Comment posted by
 Warboy
Sep 07, 07:40
i'm not going to debug the fmp.

The issue was updated with the following change(s):
  • The status has been updated, from New to Not a bug.
  • This issue has been closed
  • The resolution has been updated, from Not determined to NOT AN ISSUE.
  • This issue's progression has been updated to 100 percent completed.
#6
Comment posted by
 Myk
Sep 08, 05:25
Hey Warboy, I've been trying to figure this out with Hobbes (the creator of the map in question) at http://openxcom.org/forum/index.php?topic=2358.msg31700#msg31700 He asks if there is a limit to the number of route nodes in a battlescape. Is there?
#7
Comment posted by
 Warboy
icon_reply.pngSep 08, 05:46, in reply to comment #6
RMP files store the data as unsigned 8-bit values, so yes, the limit is 256 (0-255).

Myk wrote:
Hey Warboy, I've been trying to figure this out with Hobbes (the creator of
the map in question) at
http://openxcom.org/forum/index.php?topic=2358.msg31700#msg31700
He asks if there is a limit to the number of route nodes in a battlescape.
Is there?


#8
Comment posted by
 Myk
icon_reply.pngSep 08, 15:54, in reply to comment #7
Cool, thanks -- I communicated that to Hobbes, and he has a followup question:

"So the 256 limit not only applies to RMP files but to the total of nodes in a Battlescape as well? This is the issue I need to confirm since this doesn't happen with the MCD files - they also have a 256 limit but you can use more than 256 entries during a tactical fight.

Or, an even better question: hat wdoes Warboy think it is the cause of the error message?

Sorry for all these questions but I'm not really qualified to understand that bug report since I hardly know any coding."
#9
Comment posted by
 volutar
icon_reply.pngSep 09, 04:42, in reply to comment #8
Save file is screwed. There is no id=254 and id=253 and id=252/247 are set twice.

So it can't be used to test if this bug is fixed anyways.
#10
Comment posted by
 SupSuper
icon_reply.pngSep 09, 05:05, in reply to comment #8
You can have infinite nodes on the Battlescape, but only 255 per RMP (and id=255 means none).

Anyways we've fixed a bug that might've caused these buggy node IDs by making nodes wrap around at 128. However there's no easy way to fix this save, the mission has to be aborted/cheated/etc.

Myk wrote:
Cool, thanks -- I communicated that to Hobbes, and he has a followup
question:

"So the 256 limit not only applies to RMP files but to the total of nodes
in a Battlescape as well? This is the issue I need to confirm since this
doesn't happen with the MCD files - they also have a 256 limit but you can
use more than 256 entries during a tactical fight.

Or, an even better question: hat wdoes Warboy think it is the cause of the
error message?

Sorry for all these questions but I'm not really qualified to understand
that bug report since I hardly know any coding."


#11
Comment posted by
 Myk
Sep 09, 06:43
thx guys! I wish I'd saved the game before the mission so I could try replaying it, but I'll keep an eye out for this map to see if it works in the future.
#12
Comment posted by
 volutar
icon_reply.pngSep 09, 11:17, in reply to comment #11
You can skip alien move, or manually edit savegame - convert it into geoscape.

Myk wrote:
thx guys! I wish I'd saved the game before the mission so I could try
replaying it, but I'll keep an eye out for this map to see if it works in
the future.