fheroes2enh icon indicating copy to clipboard operation
fheroes2enh copied to clipboard

Error: attempt to subscript container with out-of-bounds index 0

Open phoe opened this issue 5 years ago • 9 comments

Built on debian sid. Trying to run the resulting binary gives me:

/usr/include/c++/8/debug/vector:417:
Error: attempt to subscript container with out-of-bounds index 0, but 
container only holds 0 elements.

Objects involved in the operation:
    sequence "this" @ 0x0x55ed94072420 {
      type = std::__debug::vector<int, std::allocator<int> >;
    }
Aborted

This happens both in release and debug builds.

phoe avatar Mar 29 '19 17:03 phoe

May you give a full stack?

ciplogic avatar Apr 01 '19 09:04 ciplogic

How do I produce it?

phoe avatar Apr 01 '19 09:04 phoe

For example running in GDB:

https://cs.baylor.edu/~donahoo/tools/gdb/tutorial.html

ciplogic avatar Apr 01 '19 09:04 ciplogic

Also, after running using 'run' in gdb you have multiple options:

https://stackoverflow.com/questions/7848771/how-can-one-see-content-of-stack-with-gdb

ciplogic avatar Apr 01 '19 09:04 ciplogic

┌─[phoe][phoetower][±][master ?:4 ✗][/tmp/fheroes2enh]
└─▪ gdb fheroes2
GNU gdb (Debian 8.2.1-2) 8.2.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from fheroes2...done.
(gdb) (run)
Undefined command: "".  Try "help".
(gdb) run
Starting program: /tmp/fheroes2enh/fheroes2 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
/usr/include/c++/8/debug/vector:417:
Error: attempt to subscript container with out-of-bounds index 0, but 
container only holds 0 elements.

Objects involved in the operation:
    sequence "this" @ 0x0x55555ca852c0 {
      type = std::__debug::vector<int, std::allocator<int> >;
    }

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50	../sysdeps/unix/sysv/linux/raise.c: Nie ma takiego pliku ani katalogu.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff6083535 in __GI_abort () at abort.c:79
#2  0x00007ffff6f6e77d in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00005555582f12e1 in std::__debug::vector<int, std::allocator<int> >::operator[] (
    this=0x55555ca852c0 <(anonymous namespace)::pathPointsMap2>, __n=0) at /usr/include/c++/8/debug/vector:417
#4  0x0000555558d664b1 in (anonymous namespace)::PathMap::clear (
    this=0x55555ca852c0 <(anonymous namespace)::pathPointsMap2>)
    at /tmp/fheroes2enh/src/fheroes2/heroes/route_pathfind.cpp:254
#5  0x0000555558d66c72 in (anonymous namespace)::PathMap::PathMap (
    this=0x55555ca852c0 <(anonymous namespace)::pathPointsMap2>, sizePow2=10)
    at /tmp/fheroes2enh/src/fheroes2/heroes/route_pathfind.cpp:261
#6  0x0000555558d75321 in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535)
    at /tmp/fheroes2enh/src/fheroes2/heroes/route_pathfind.cpp:302
#7  0x0000555558d75356 in _GLOBAL__sub_I__Z16GetCurrentLengthRNSt7__debug3mapIi6cell_tSt4lessIiESaISt4pairIKiS1_EEEEi
    () at /tmp/fheroes2enh/src/fheroes2/heroes/route_pathfind.cpp:434
#8  0x0000555559258f15 in __libc_csu_init ()
#9  0x00007ffff608502a in __libc_start_main (main=0x5555589d671c <main(int, char**)>, argc=1, argv=0x7fffffffe598, 
    init=0x555559258ed0 <__libc_csu_init>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffe588)
    at ../csu/libc-start.c:264
#10 0x0000555557ecd3ea in _start ()
(gdb) 

phoe avatar Apr 01 '19 09:04 phoe

It looks you start a game and right after it loads the map it fails with pathfinding.... is it correct?

Did you try to load a map or something?

ciplogic avatar Apr 01 '19 09:04 ciplogic

No, it does not even display any GUI. It crashes straight after running.

phoe avatar Apr 01 '19 09:04 phoe

This is weird. Is Your Debian set-up is different from default in any way? gcc/glibc version? I'll try it out on my Debian machine later.

kamiccolo avatar Apr 02 '19 15:04 kamiccolo

I don't think so. I haven't done any weird modifications.

┌─[phoe][phoetower][~]
└─▪ ldd --version
ldd (Debian GLIBC 2.28-5) 2.28

phoe avatar Apr 02 '19 15:04 phoe