News:

Simutrans Forum Archive
A complete record of the old Simutrans Forum.

Index out of bounds error

Started by ACarlotti, April 20, 2019, 09:22:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ACarlotti

Some signalling bug causing an out of range error in this savegame.

I have an index out of range error - I think it was caused by triggering a choose signal close to the end of the route. A full backtrace, and the values of some variables, are included here:


(gdb) backtrace
#0  0x00007ffff775cd7f in raise () from /usr/lib/libc.so.6
#1  0x00007ffff7747672 in abort () from /usr/lib/libc.so.6
#2  0x00005555559a2a38 in log_t::fatal (this=0x555555cd11b0, who=0x555555a0ff4b "vector_tpl<T>::[]", format=0x555555a0ff20 "%s: index out of bounds: %lu not in 0..%lu") at utils/log.cc:346
#3  0x00005555555e0794 in vector_tpl<koord3d>::operator[] (this=0x5555a09438e8, i=11) at bauer/../tpl/vector_tpl.h:282
#4  0x0000555555614edc in route_t::at (this=0x5555a09438e8, n=11) at boden/../dataobj/route.h:109
#5  0x00005555559c878f in rail_vehicle_t::activate_choose_signal (this=0x5555a0947f50, start_block=10, next_signal_index=@0x7fffffffbbc0: 65530, brake_steps=5, modified_sighting_distance_tiles=6, route=0x5555a09438e8, modified_route_index=9) at vehicle/simvehicle.cc:4777
#6  0x00005555559d3e10 in rail_vehicle_t::block_reserver (this=0x5555a0947f50, route=0x5555a09438e8, start_index=9, modified_sighting_distance_tiles=6, next_signal_index=@0x7fffffffbbc0: 65530, count=0, reserve=true, force_unreserve=false, is_choosing=false, is_from_token=false, is_from_starter=false,
    is_from_directional=false, brake_steps=5, first_one_train_staff_index=65530, from_call_on=false, break_loop=0x0) at vehicle/simvehicle.cc:7064
#7  0x00005555559cd9b1 in rail_vehicle_t::can_enter_tile (this=0x5555a0947f50, gr=0x55557f3a4228, restart_speed=@0x7fffffffbdd4: -1) at vehicle/simvehicle.cc:5560
#8  0x00005555559b9d94 in vehicle_t::hop_check (this=0x5555a0947f50) at vehicle/simvehicle.cc:1601
#9  0x00005555559b4a15 in vehicle_base_t::do_drive (this=0x5555a0947f50, distance=11077) at vehicle/simvehicle.cc:373
#10 0x00005555558b263a in convoi_t::sync_step (this=0x5555a0943850, delta_t=100) at simconvoi.cc:1317
#11 0x000055555597bf2c in karte_t::sync_list_t::sync_step (this=0x555558ea14a0, delta_t=100) at simworld.cc:4586
#12 0x000055555597c196 in karte_t::sync_step (this=0x555558e9c610, delta_t=100, do_sync_step=true, display=false) at simworld.cc:4657
#13 0x00005555559931da in karte_t::interactive (this=0x555558e9c610, quit_month=2147483647) at simworld.cc:10394
#14 0x0000555555924968 in simu_main (argc=7, argv=0x7fffffffe938) at simmain.cc:1382
#15 0x0000555555937f88 in sysmain (argc=7, argv=0x7fffffffe938) at simsys.cc:825
#16 0x0000555555a0c7a7 in main (argc=7, argv=0x7fffffffe938) at simsys_s2.cc:792
(gdb) frame 3
#3  0x00005555555e0794 in vector_tpl<koord3d>::operator[] (this=0x5555a09438e8, i=11) at bauer/../tpl/vector_tpl.h:282
282                                     dbg->fatal("vector_tpl<T>::[]", "%s: index out of bounds: %lu not in 0..%lu", typeid(T).name(), i, count - 1);
(gdb) print(i)
$1 = 11
(gdb) print(count)
$2 = 11
(gdb) frame 4
#4  0x0000555555614edc in route_t::at (this=0x5555a09438e8, n=11) at boden/../dataobj/route.h:109
109             const koord3d& at(const uint16 n) const { return route[n]; }
(gdb) frame 5
#5  0x00005555559c878f in rail_vehicle_t::activate_choose_signal (this=0x5555a0947f50, start_block=10, next_signal_index=@0x7fffffffbbc0: 65530, brake_steps=5, modified_sighting_distance_tiles=6, route=0x5555a09438e8, modified_route_index=9) at vehicle/simvehicle.cc:4777
4777            const koord3d third_tile = route->at(third_block);
(gdb) print(start_block)
$3 = 10
(gdb) print(pos)
$4 = {x = 1372, y = 2210, z = 9 '\t', static invalid = {x = -1, y = -1, z = -1 '\377', static invalid = <same as static member of an already seen type>}}
(gdb) route->at(10)
Undefined command: "route->at".  Try "help".
(gdb) print(route->at(10))
$5 = (const koord3d &) @0x5555a0946ec2: {x = 1372, y = 2212, z = 9 '\t', static invalid = {x = -1, y = -1, z = -1 '\377', static invalid = <same as static member of an already seen type>}}
(gdb) print(route->at(9))
$6 = (const koord3d &) @0x5555a0946ebd: {x = 1372, y = 2211, z = 9 '\t', static invalid = {x = -1, y = -1, z = -1 '\377', static invalid = <same as static member of an already seen type>}}
(gdb) print(route->at()
$7 = (const koord3d &) @0x5555a0946eb8: {x = 1372, y = 2210, z = 9 '\t', static invalid = {x = -1, y = -1, z = -1 '\377', static invalid = <same as static member of an already seen type>}}
(gdb) print(route->at(7))
$8 = (const koord3d &) @0x5555a0946eb3: {x = 1372, y = 2209, z = 9 '\t', static invalid = {x = -1, y = -1, z = -1 '\377', static invalid = <same as static member of an already seen type>}}
(gdb) print(route->at(6))
$9 = (const koord3d &) @0x5555a0946eae: {x = 1372, y = 2208, z = 9 '\t', static invalid = {x = -1, y = -1, z = -1 '\377', static invalid = <same as static member of an already seen type>}}
(gdb) print(route->at(5))
$10 = (const koord3d &) @0x5555a0946ea9: {x = 1371, y = 2208, z = 9 '\t', static invalid = {x = -1, y = -1, z = -1 '\377', static invalid = <same as static member of an already seen type>}}
(gdb) print(route->at(4))
$11 = (const koord3d &) @0x5555a0946ea4: {x = 1371, y = 2207, z = 9 '\t', static invalid = {x = -1, y = -1, z = -1 '\377', static invalid = <same as static member of an already seen type>}}
(gdb) print(route->at(3))
$12 = (const koord3d &) @0x5555a0946e9f: {x = 1370, y = 2207, z = 9 '\t', static invalid = {x = -1, y = -1, z = -1 '\377', static invalid = <same as static member of an already seen type>}}
(gdb) print(route->at(2))
$13 = (const koord3d &) @0x5555a0946e9a: {x = 1369, y = 2207, z = 9 '\t', static invalid = {x = -1, y = -1, z = -1 '\377', static invalid = <same as static member of an already seen type>}}
(gdb) print(route->at(1))
$14 = (const koord3d &) @0x5555a0946e95: {x = 1368, y = 2207, z = 9 '\t', static invalid = {x = -1, y = -1, z = -1 '\377', static invalid = <same as static member of an already seen type>}}
(gdb) print(route->at(0))
$15 = (const koord3d &) @0x5555a0946e90: {x = 1367, y = 2207, z = 9 '\t', static invalid = {x = -1, y = -1, z = -1 '\377', static invalid = <same as static member of an already seen type>}}


I'll try testing a few more times to see what else I can trigger.

Edit: I got the same error again - it was triggered by a three-car DLR train (the only one on the Bank-Lewisham line) approaching the choose signal at the end of the SB platform at Crossharbour, while a train in front entering the bay platform at Mudchute was still blocking the junction.
On a third attempt, when I took it off fastforward before the three-car train arrived, the train in front tried entering the occupied bay platform, leading to a gridlock. After putting it back on fastforward, further trains apporaching from the south began piling up and occupying the same space.

Edit 2: Reproducible without fastforward as well.

Edit 3: For reference, the train concerned is heading towards Bank and is just outside the tunnel (in a queue of trains) in the save provided. I have run it twice more (once with no debugging, and once with a debug build in gdb (again), and the same out-of-range error occurs.

Something else of note is that sometimes trains end up entering the bay platform at a reported speed of 1km/h, when the bay is clear and there is no reason for them to be going so slowly.

jamespetts

I believe that I fixed this a few commits back and forgot to update this thread.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.