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

Assertion failure when removing company #9348

Closed
JGRennison opened this issue Jun 10, 2021 · 0 comments
Closed

Assertion failure when removing company #9348

JGRennison opened this issue Jun 10, 2021 · 0 comments

Comments

@JGRennison
Copy link
Contributor

@JGRennison JGRennison commented Jun 10, 2021

crash-pr9300.zip

Version of OpenTTD

master (since #9300)

Steps to reproduce

Remove a company such as by bankruptcy or the stop_ai command.

Company::Get is called on INVALID_OWNER when setting share_owners to COMPANY_SPECTATOR

Stack trace:

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff5ed5859 in __GI_abort () at abort.c:79
#2  0x00007ffff5ed5729 in __assert_fail_base (fmt=0x7ffff606b588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x555568dd27c0 "index < this->first_unused", 
    file=0x555568dd23c0 "/home/jgr/misc/openttd-2/src/script/api/../../core/pool_type.hpp", line=111, function=<optimised out>) at assert.c:92
#3  0x00007ffff5ee6f36 in __GI___assert_fail (assertion=0x555568dd27c0 "index < this->first_unused", file=0x555568dd23c0 "/home/jgr/misc/openttd-2/src/script/api/../../core/pool_type.hpp", line=111, 
    function=0x555568dd2660 "Titem* Pool<Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero>::Get(size_t) [with Titem = Company; Tindex = Owner; long unsigned int Tgrowth_step = 1; long unsigned int Tmax_size = 15;"...)
    at assert.c:101
#4  0x0000555565ddbe3c in Pool<Company, Owner, 1ul, 15ul, (PoolType)1, false, true>::Get (this=0x55557fc299e0 <_company_pool>, index=255) at /home/jgr/misc/openttd-2/src/script/api/../../core/pool_type.hpp:111
#5  0x0000555565ddb533 in Pool<Company, Owner, 1ul, 15ul, (PoolType)1, false, true>::PoolItem<&_company_pool>::Get (index=255) at /home/jgr/misc/openttd-2/src/script/api/../../core/pool_type.hpp:331
#6  0x000055556714f3a6 in ChangeOwnershipOfCompanyItems (old_owner=1, new_owner=-1) at /home/jgr/misc/openttd-2/src/economy.cpp:329
#7  0x0000555566f9d8e8 in CmdCompanyCtrl (tile=0, flags=DC_EXEC, p1=65538, p2=1, text="") at /home/jgr/misc/openttd-2/src/company_cmd.cpp:901
#8  0x0000555566f8e02c in DoCommandPInternal (tile=0, p1=65538, p2=1, cmd=81, callback=0x0, text="", my_cmd=true, estimate_only=false) at /home/jgr/misc/openttd-2/src/command.cpp:725
#9  0x0000555566f8cca2 in DoCommandP (tile=0, p1=65538, p2=1, cmd=81, callback=0x0, text="", my_cmd=true) at /home/jgr/misc/openttd-2/src/command.cpp:589
#10 0x000055556705d122 in ConStopAI (argc=2 '\002', argv=0x7fffffffbe10) at /home/jgr/misc/openttd-2/src/console_cmds.cpp:1309
#11 0x0000555567039066 in IConsoleCmdExec (cmdstr=0x60200014b210 "stopai 2", recurse_count=0) at /home/jgr/misc/openttd-2/src/console.cpp:448
#12 0x00005555670b5656 in IConsoleWindow::OnKeyPress (this=0x61200044f140, key=13 U'\r', keycode=13) at /home/jgr/misc/openttd-2/src/console_gui.cpp:294
#13 0x00005555689937d7 in HandleKeypress (keycode=13, key=13 U'\r') at /home/jgr/misc/openttd-2/src/window.cpp:2619
#14 0x0000555566d36f1d in VideoDriver_SDL_Base::PollEvent (this=0x61a000000680) at /home/jgr/misc/openttd-2/src/video/sdl2_v.cpp:479
#15 0x0000555566d686fe in VideoDriver::Tick (this=0x61a000000680) at /home/jgr/misc/openttd-2/src/video/video_driver.cpp:144
#16 0x0000555566d38e72 in VideoDriver_SDL_Base::LoopOnce (this=0x61a000000680) at /home/jgr/misc/openttd-2/src/video/sdl2_v.cpp:642
#17 0x0000555566d39237 in VideoDriver_SDL_Base::MainLoop (this=0x61a000000680) at /home/jgr/misc/openttd-2/src/video/sdl2_v.cpp:660
#18 0x0000555567c893b0 in openttd_main (argc=2, argv=0x7fffffffdbb8) at /home/jgr/misc/openttd-2/src/openttd.cpp:800
#19 0x000055556697881c in main (argc=2, argv=0x7fffffffdbb8) at /home/jgr/misc/openttd-2/src/os/unix/unix.cpp:262
TrueBrain added a commit to TrueBrain/OpenTTD that referenced this issue Jun 10, 2021
"new_owner" can be INVALID_OWNER, and as INVALID_OWNER ==
COMPANY_SPECTATORS, we could end up trying to sell shares of
nobody.
TrueBrain added a commit to TrueBrain/OpenTTD that referenced this issue Jun 10, 2021
"new_owner" can be INVALID_OWNER, and as INVALID_OWNER ==
COMPANY_SPECTATORS, we could end up trying to sell shares of
nobody.
TrueBrain added a commit that referenced this issue Jun 10, 2021
"new_owner" can be INVALID_OWNER, and as INVALID_OWNER ==
COMPANY_SPECTATORS, we could end up trying to sell shares of
nobody.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

1 participant