ciplogic / fheroes2enh

Free Heroes 2 - Enhanced
Other
135 stars 19 forks source link

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

Open phoe opened 5 years ago

phoe commented 5 years ago

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.

ciplogic commented 5 years ago

May you give a full stack?

phoe commented 5 years ago

How do I produce it?

ciplogic commented 5 years ago

For example running in GDB:

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

ciplogic commented 5 years ago

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

phoe commented 5 years ago
┌─[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) 
ciplogic commented 5 years ago

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?

phoe commented 5 years ago

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

kamiccolo commented 5 years ago

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.

phoe commented 5 years ago

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

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