Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Game crash from out-of-bounds helicopter, infinite circling with superfast aircraft #7619

Open
James103 opened this issue Jun 6, 2019 · 2 comments

Comments

@James103
Copy link
Contributor

@James103 James103 commented Jun 6, 2019

Version of OpenTTD

20190525-master-gef74af6766

Expected result

Game does not crash and both aircraft land properly.

Actual result

A. When you repeatedly start/stop any helicopter under certain conditions (such as below), the game can crash with Assertion failed at line 100 of d:\a\1\s\src\tile_map.h: tile < MapSize() due to an out-of-bounds position for that aircraft. This may be related to #272.
Crash files have been attached.

B. When a regular aircraft (such as the Arwing) that is going very fast (>4000 km/h) tries to land in an airport, it circles around the destination airport infinitely. This has the following effects:

  • The aircraft can't be stopped as it is in flight.
  • The aircraft will continue to circle around the airport, but in a different way in that the circle is tighter/smaller and goes clockwise relative to the airport runway that it is tangent to.
  • The aircraft will be unable to escape that circling state, even when told to go to a different airport/hangar.
  • All of that means that the aircraft is effectively stuck there, unable to be removed.

Savegame attached for clarification.

Steps to reproduce

  1. Start new game (64x4096) with OpenGFX Airports v0.5.0 (disable "Airport noise limits") and Kasskroket's Fictional Aircraft v1.0.2 (disable "Limit Arwing top speed").
  2. Build Intercontinental airport at top of the map (1,1).
  3. Build airport at bottom of the map (1,4095). Save the game.
  4. Purchase any helicopter at the top airport and add the top airport to its orders.
  5. Start the helicopter.
  6. After some time, repeatedly start/stop the helicopter while fastforwarding.
  7. After a while, the game will crash with Assertion failed at line 100 of d:\a\1\s\src\tile_map.h: tile < MapSize() because it accesses an out-of-bounds/invalid tile from the map array.
  8. Reload the save you made in step 3.
  9. Purchase "Arwing" aircraft and add both airports to its orders.
  10. Start the aircraft.
  11. When the aircraft gets to the destination, it will circle around indefinitely.
@James103 James103 changed the title Game crash from superfast helicopter, infinite circling with superfast aircraft Game crash from out-of-bounds helicopter, infinite circling with superfast aircraft Jun 7, 2019
@Ben79487

This comment has been minimized.

Copy link

@Ben79487 Ben79487 commented Jul 12, 2019

I don't think this scenario is likely to occur in a game...

@LordAro

This comment has been minimized.

Copy link
Member

@LordAro LordAro commented Nov 2, 2019

This should really be separate issues, but whatever

First issue is crashing the game due to trying to render the error message ("aircraft cannot be stopped") at an invalid tile:

#0  0x00007ffce83da839 in RaiseException () from C:\WINDOWS\System32\KernelBase.dll
#1  0x00007ffcea39ae7b in raise () from C:\WINDOWS\System32\msvcrt.dll
#2  0x00007ffcea39dab9 in msvcrt!_wassert () from C:\WINDOWS\System32\msvcrt.dll
#3  0x00000000004d34c2 in GetTileType (tile=tile@entry=268436981) at C:/msys64/home/LordAro/OpenTTD/src/tile_map.h:101
#4  0x00000000004d551d in GetSlopePixelZ (x=3920, y=16777296) at C:/msys64/home/LordAro/OpenTTD/src/landscape.cpp:348
#5  0x0000000000481823 in RemapCoords2 (x=3920, y=16777296) at C:/msys64/home/LordAro/OpenTTD/src/landscape.h:102
#6  0x0000000000724833 in ErrmsgWindow::OnInitialPosition (this=0x315179b0, sm_width=<optimized out>, sm_height=<optimized out>,
    window_number=<optimized out>) at C:/msys64/home/LordAro/OpenTTD/src/error_gui.cpp:229
#7  0x00000000006a089a in Window::FinishInitNested (this=0x315179b0, window_number=0)
    at C:/msys64/home/LordAro/OpenTTD/src/window.cpp:1832
#8  0x00000000006a0928 in Window::InitNested (this=<optimized out>, window_number=<optimized out>)
    at C:/msys64/home/LordAro/OpenTTD/src/window.cpp:1844
#9  0x00000000007249b0 in ErrmsgWindow::ErrmsgWindow (this=0x315179b0, data=...)
    at C:/msys64/home/LordAro/OpenTTD/src/error_gui.cpp:184
#10 0x0000000000482258 in ShowErrorMessage (summary_msg=<optimized out>, detailed_msg=65535, wl=wl@entry=WL_INFO, x=x@entry=3920,
    y=y@entry=16777296, textref_stack_grffile=textref_stack_grffile@entry=0x0, textref_stack_size=0,
    textref_stack=0xbdf3c0 <CommandCost::textref_stack>) at C:/msys64/home/LordAro/OpenTTD/src/error_gui.cpp:425
#11 0x000000000045ea22 in DoCommandP (tile=268436981, p1=13, p2=0, cmd=245301353, callback=0x0, text=0x0, my_cmd=true)
    at C:/msys64/home/LordAro/OpenTTD/src/command.cpp:587
#12 0x000000000067a29c in StartStopVehicle (v=0x31319810, texteffect=<optimized out>)
    at C:/msys64/home/LordAro/OpenTTD/src/vehicle_gui.cpp:2400
...

Note the y value of 16777296 for ShowErrorMessage. This is due to the vehicle's tile being invalid and outside of the range of the map, caused by the intercontinental airport's holding pattern being as wide as it is. I don't think it's distinct to helicopters, but I've been unable to reproduce with standard aircraft. Something to do with the circling pattern, perhaps?

Not sure whether the best course of action to fix that would be - it's not enough just to add some clamps to ShowErrorMessage, as the vehicle's position is invalid - it will just cause other issues later on (e.g. when saving). Could perhaps adjust the intercontinental airport's holding pattern?

The other issue is similarly niche. It only seems to happen when the aircraft approaches from certain directions - from the north east doesn't seem to trigger it, but from the south west (and presumably north west as per original report) does. Adding some print statements in indicates that the aircraft is stuck in movement data index "19" (for city airport) and just never leaves it. Presumably it's just going fast enough to go "past" the end of the pattern and being forced to begin it again? This requires further debugging though

JGRennison added a commit to JGRennison/OpenTTD-patches that referenced this issue Nov 7, 2019
JGRennison added a commit to JGRennison/OpenTTD-patches that referenced this issue Nov 13, 2019
JGRennison added a commit to JGRennison/Upstream-OpenTTD that referenced this issue Nov 13, 2019
This fixes part A of OpenTTD#7619, but not part B.

Vehicle::x_pos and Vehicle::y_pos are not required to be within the map bounds.

See also: GetTileHeightBelowAircraft()
nielsmh added a commit that referenced this issue Nov 14, 2019
This fixes part A of #7619, but not part B.

Vehicle::x_pos and Vehicle::y_pos are not required to be within the map bounds.

See also: GetTileHeightBelowAircraft()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.