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

[Crash]: Assertion triggered when getting nearest town of rotated airport #11629

Closed
JGRennison opened this issue Dec 26, 2023 · 1 comment · Fixed by #11631
Closed

[Crash]: Assertion triggered when getting nearest town of rotated airport #11629

JGRennison opened this issue Dec 26, 2023 · 1 comment · Fixed by #11631

Comments

@JGRennison
Copy link
Contributor

Version of OpenTTD

Since #11565, c0ea058

Steps to reproduce

Build a rotated airport, or load a savegame containing a rotated airport

e.g. using the OpenGFX airports GRF

Upload crash files

One or both of

		assert(IsInsideBS(TileX(cur_tile), perimeter_min_x, as->size_x));
		assert(IsInsideBS(TileY(cur_tile), perimeter_min_y, as->size_y));

in AirportGetNearestTown is triggered

openttd: /home/jgr/openttd/trunk/src/station_cmd.cpp:2327: Town* AirportGetNearestTown(const AirportSpec*, TileIndex, const TileIterator&, uint&): Assertion `IsInsideBS(TileY(cur_tile), perimeter_min_y, as->size_y)' failed.

Thread 1 "openttd" received signal SIGABRT, Aborted.
__pthread_kill_implementation (no_tid=0, signo=6, threadid=140737275480832) at ./nptl/pthread_kill.c:44
44	./nptl/pthread_kill.c: No such file or directory.
(gdb) bt
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=140737275480832) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=140737275480832) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=140737275480832, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x00007ffff6f9b476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x00007ffff6f817f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x00007ffff6f8171b in __assert_fail_base
    (fmt=0x7ffff7136130 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55555619f618 "IsInsideBS(TileY(cur_tile), perimeter_min_y, as->size_y)", file=0x55555619f4d0 "/home/jgr/openttd/trunk/src/station_cmd.cpp", line=2327, function=<optimised out>) at ./assert/assert.c:92
#6  0x00007ffff6f92e96 in __GI___assert_fail
    (assertion=0x55555619f618 "IsInsideBS(TileY(cur_tile), perimeter_min_y, as->size_y)", file=0x55555619f4d0 "/home/jgr/openttd/trunk/src/station_cmd.cpp", line=2327, function=0x55555619f580 "Town* AirportGetNearestTown(const AirportSpec*, TileIndex, const TileIterator&, uint&)") at ./assert/assert.c:101
#7  0x0000555555fd1b1e in AirportGetNearestTown(AirportSpec const*, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, TileIterator const&, unsigned int&) (as=0x555556552700 <AirportSpec::specs+1120>, tile=..., it=<optimised out>, mindist=@0x7fffffffcc10: 14) at /home/jgr/openttd/trunk/src/station_cmd.cpp:2327
#8  0x0000555555fdc83c in CmdBuildAirport(DoCommandFlag, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, unsigned char, unsigned char, unsigned short, bool) (flags=flags@entry=(DC_AUTO | DC_NO_WATER), tile=..., airport_type=<optimised out>, layout=<optimised out>, station_to_join=<optimised out>, allow_adjacent=false) at /home/jgr/openttd/trunk/src/station_cmd.cpp:2405
#9  0x0000555555cbcb80 in std::__invoke_impl<CommandCost, CommandCost (&)(DoCommandFlag, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, unsigned char, unsigned char, unsigned short, bool), DoCommandFlag, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, unsigned char, unsigned char, unsigned short, bool>(std::__invoke_other, CommandCost (&)(DoCommandFlag, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, unsigned char, unsigned char, unsigned short, bool), DoCommandFlag&&, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >&&, unsigned char&&, unsigned char&&, unsigned short&&, bool&&) (__f=<optimised out>) at /usr/include/c++/11/bits/invoke.h:60
#10 std::__invoke<CommandCost (&)(DoCommandFlag, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, unsigned char, unsigned char, unsigned short, bool), DoCommandFlag, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, unsigned char, unsigned char, unsigned short, bool>(CommandCost (&)(DoCommandFlag, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, unsigned char, unsigned char, unsigned short, bool), DoCommandFlag&&, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >&&, unsigned char&&, unsigned char&&, unsigned short&&, bool&&)
    (__fn=<optimised out>) at /usr/include/c++/11/bits/invoke.h:97
#11 std::__apply_impl<CommandCost (&)(DoCommandFlag, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, unsigned char, unsigned char, unsigned short, bool), std::tuple<DoCommandFlag, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, unsigned char, unsigned char, unsigned short, bool>, 0ul, 1ul, 2ul, 3ul, 4ul, 5ul>(CommandCost (&)(DoCommandFlag, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, unsigned char, unsigned char, unsigned short, bool), std::tuple<DoCommandFlag, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, unsigned char, unsigned char, unsigned short, bool>&&, std::integer_sequence<unsigned long, 0ul, 1ul, 2ul, 3ul, 4ul, 5ul>) (__t=..., __f=<optimised out>) at /usr/include/c++/11/tuple:1855
#12 std::apply<CommandCost (&)(DoCommandFlag, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, unsigned char, unsigned char, unsigned short, bool), std::tuple<DoCommandFlag, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, unsigned char, unsigned char, unsigned short, bool> >(CommandCost (&)(DoCommandFlag, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, unsigned char, unsigned char, unsigned short, bool), std::tuple<DoCommandFlag, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, unsigned char, unsigned char, unsigned short, bool>&&)
    (__t=..., __f=<optimised out>) at /usr/include/c++/11/tuple:1867
#13 CommandHelper<(Commands)26, CommandCost (*)(DoCommandFlag, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, unsigned char, unsigned char, unsigned short, bool), true>::Execute(unsigned int, void (*)(Commands, CommandCost const&, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >), bool, bool, bool, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, std::tuple<StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, unsigned char, unsigned char, unsigned short, bool>)
    (args=std::tuple containing = {...}, tile=..., network_command=false, estimate_only=false, callback=0x555555cb8360 <CcBuildAirport(Commands, CommandCost const&, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >)>, err_message=3847) at /home/jgr/openttd/trunk/src/command_func.h:384
#14 CommandHelper<(Commands)26, CommandCost (*)(DoCommandFlag, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, unsigned char, unsigned char, unsigned short, bool), true>::InternalPost<void (Commands, CommandCost const&, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >)>(unsigned int, void (*)(Commands, CommandCost const&, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >), bool, bool, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, std::tuple<StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, unsigned char, unsigned char, unsigned short, bool>)
     (args=std::tuple containing = {...}, tile=..., network_command=false, my_cmd=true, callback=0x555555cb8360 <CcBuildAirport(Commands, CommandCost const&, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >)>, err_message=3847)
    at /home/jgr/openttd/trunk/src/command_func.h:305
#15 CommandHelper<(Commands)26, CommandCost (*)(DoCommandFlag, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, unsigned char, unsigned char, unsigned short, bool), true>::InternalPost<void (Commands, CommandCost const&, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >)>(unsigned int, void (*)(Commands, CommandCost const&, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >), bool, bool, std::tuple<StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, unsigned char, unsigned char, unsigned short, bool>)
   
     (args=std::tuple containing = {...}, network_command=false, my_cmd=true, callback=0x555555cb8360 <CcBuildAirport(Commands, CommandCost const&, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >)>, err_message=3847)
    at /home/jgr/openttd/trunk/src/command_func.h:290
--Type <RET> for more, q to quit, c to continue without paging--
#16 CommandHelper<(Commands)26, CommandCost (*)(DoCommandFlag, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, unsigned char, unsigned char, unsigned short, bool), true>::Post<void (Commands, CommandCost const&, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >)>(unsigned int, void (*)(Commands, CommandCost const&, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >), StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >, unsigned char, unsigned char, unsigned short, bool)
   
     (args#4=<optimised out>, args#3=<optimised out>, args#2=3 '\003', args#1=<optimised out>, args#0=..., callback=0x555555cb8360 <CcBuildAirport(Commands, CommandCost const&, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >)>, err_message=3847)
    at /home/jgr/openttd/trunk/src/command_func.h:210
#17 operator() (__closure=<optimised out>, __closure=<optimised out>, to_join=<optimised out>, test=false) at /home/jgr/openttd/trunk/src/airport_gui.cpp:74
#18 std::__invoke_impl<bool, PlaceAirport(TileIndex)::<lambda(bool, StationID)>&, bool, short unsigned int> (__f=<optimised out>) at /usr/include/c++/11/bits/invoke.h:61
#19 std::__invoke_r<bool, PlaceAirport(TileIndex)::<lambda(bool, StationID)>&, bool, short unsigned int> (__fn=<optimised out>) at /usr/include/c++/11/bits/invoke.h:114
#20 std::_Function_handler<bool(bool, short unsigned int), PlaceAirport(TileIndex)::<lambda(bool, StationID)> >::_M_invoke(const std::_Any_data &, bool &&, unsigned short &&)
    (__functor=<optimised out>, __args#0=<optimised out>, __args#1=<optimised out>) at /usr/include/c++/11/bits/std_function.h:290
#21 0x0000555555ff4474 in std::function<bool (bool, unsigned short)>::operator()(bool, unsigned short) const (__args#1=<optimised out>, __args#0=<optimised out>, this=0x7fffffffce50) at /usr/include/c++/11/bits/std_function.h:590
#22 ShowSelectBaseStationIfNeeded<Station>(OrthogonalTileArea, std::function<bool (bool, unsigned short)>&&) (ta=..., proc=...) at /home/jgr/openttd/trunk/src/station_gui.cpp:2453
#23 0x0000555555feda89 in ShowSelectStationIfNeeded(OrthogonalTileArea, std::function<bool (bool, unsigned short)>) (ta=..., proc=...) at /home/jgr/openttd/trunk/src/station_gui.cpp:2464
#24 0x0000555555cbb3be in PlaceAirport (tile=...) at /home/jgr/openttd/trunk/src/airport_gui.cpp:78
#25 BuildAirToolbarWindow::OnPlaceObject(Point, StrongType::Typedef<unsigned int, TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible<int>, StrongType::Compatible<long> >)
    (this=<optimised out>, pt=..., tile=...) at /home/jgr/openttd/trunk/src/airport_gui.cpp:145
#26 0x00005555560c7e95 in PlaceObject () at /home/jgr/openttd/trunk/src/viewport.cpp:2356
#27 HandleViewportClicked(Viewport const*, int, int) (vp=vp@entry=0x7fff6d52c050, x=x@entry=974, y=y@entry=409) at /home/jgr/openttd/trunk/src/viewport.cpp:2370
#28 0x00005555560e9fd9 in MouseLoop (mousewheel=0, click=MC_LEFT) at /home/jgr/openttd/trunk/src/window.cpp:2829
#29 HandleMouseEvents() () at /home/jgr/openttd/trunk/src/window.cpp:2954
#30 0x0000555555c9b035 in VideoDriver_SDL_Base::PollEvent() (this=0x55555670e8f0) at /home/jgr/openttd/trunk/src/video/sdl2_v.cpp:417
#31 0x0000555555ca4ed5 in VideoDriver::Tick() (this=this@entry=0x55555670e8f0) at /home/jgr/openttd/trunk/src/video/video_driver.cpp:135
#32 0x0000555555c98d4e in VideoDriver_SDL_Base::LoopOnce() (this=0x55555670e8f0) at /home/jgr/openttd/trunk/src/video/sdl2_v.cpp:627
#33 VideoDriver_SDL_Base::LoopOnce() (this=0x55555670e8f0) at /home/jgr/openttd/trunk/src/video/sdl2_v.cpp:600
#34 VideoDriver_SDL_Base::MainLoop() (this=0x55555670e8f0) at /home/jgr/openttd/trunk/src/video/sdl2_v.cpp:645
#35 0x0000555555f07bb8 in openttd_main(int, char**) (argc=<optimised out>, argv=<optimised out>) at /home/jgr/openttd/trunk/src/openttd.cpp:817
#36 0x00007ffff6f82d90 in __libc_start_call_main (main=main@entry=0x5555557ca170 <main(int, char**)>, argc=argc@entry=2, argv=argv@entry=0x7fffffffdba8) at ../sysdeps/nptl/libc_start_call_main.h:58
#37 0x00007ffff6f82e40 in __libc_start_main_impl (main=0x5555557ca170 <main(int, char**)>, argc=2, argv=0x7fffffffdba8, init=<optimised out>, fini=<optimised out>, rtld_fini=<optimised out>, stack_end=0x7fffffffdb98)
    at ../csu/libc-start.c:392
#38 0x000055555586d6c5 in _start ()
@PeterN
Copy link
Member

PeterN commented Dec 26, 2023

Hmm, I wonder if size_x/size_y need to be swapped.

JGRennison added a commit to JGRennison/OpenTTD-patches that referenced this issue Dec 26, 2023
JGRennison added a commit to JGRennison/Upstream-OpenTTD that referenced this issue Dec 26, 2023
Add rotation parameter to AirportGetNearestTown
Add wrapper for existing stations
Remove unnecessary iterator cloning
JGRennison added a commit to JGRennison/Upstream-OpenTTD that referenced this issue Dec 26, 2023
Add rotation parameter to AirportGetNearestTown
Add wrapper for existing stations
Remove unnecessary iterator cloning
JGRennison added a commit to JGRennison/Upstream-OpenTTD that referenced this issue Dec 26, 2023
Add rotation parameter to AirportGetNearestTown
Add wrapper for existing stations
Remove unnecessary iterator cloning
PeterN pushed a commit that referenced this issue Dec 28, 2023
Add rotation parameter to AirportGetNearestTown
Add wrapper for existing stations
Remove unnecessary iterator cloning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants