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 in abilities.cpp #5643

Closed
Pentarctagon opened this issue Mar 27, 2021 · 8 comments · Fixed by #7245
Closed

Assertion in abilities.cpp #5643

Pentarctagon opened this issue Mar 27, 2021 · 8 comments · Fixed by #7245
Labels
Bug Issues involving unexpected behavior. Engine General game engine issues that do not fit in any other category.

Comments

@Pentarctagon
Copy link
Member

Pentarctagon commented Mar 27, 2021

The details are in the thread here. The short version is that if you try to load the save file attached there (which uses Ageless Era and the Enhanced Traits mod on 1.14) you will get an assertion and Wesnoth will crash. I have not checked whether it crashes in 1.15 as well since the Enhanced Traits mod doesn't exist there so far. The backtrace from the crash is:

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff7048859 in __GI_abort () at abort.c:79
#2  0x00007ffff7048729 in __assert_fail_base
    (fmt=0x7ffff71de588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x555556a19f46 "display::get_singleton()", file=0x555556a19f2e "src/units/abilities.cpp", line=152, function=<optimized out>) at assert.c:92
#3  0x00007ffff7059f36 in __GI___assert_fail
    (assertion=0x555556a19f46 "display::get_singleton()", file=0x555556a19f2e "src/units/abilities.cpp", line=152, function=0x555556a19ed0 "bool unit::get_ability_bool(const string&, const map_location&, const display_context&) const")
    at assert.c:101
#4  0x0000555555e92cbd in unit::get_ability_bool(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, map_location const&, display_context const&) const (this=
    0x7fff73c67070, tag_name="illuminates", loc=..., dc=...) at src/units/abilities.cpp:152
#5  0x0000555555d80006 in unit::get_ability_bool(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, display_context const&) const (this=0x7fff73c67070, tag_name="illuminates", dc=...)
    at src/units/unit.hpp:1477
#6  0x0000555555e89ecf in tod_manager::get_illuminated_time_of_day(unit_map const&, gamemap const&, map_location const&, int) const (this=0x7fff7903a100, units=..., map=..., loc=..., for_turn=0) at src/tod_manager.cpp:242
#7  0x0000555555e77515 in terrain_filter::match_internal(map_location const&, unit const*, bool) const (this=0x7fff8f7fcba0, loc=..., ref_unit=0x0, ignore_xy=false) at src/terrain/filter.cpp:265
#8  0x0000555555e797e5 in terrain_filter::match_impl(map_location const&, unit const*) const (this=0x7fff8f7fcba0, loc=..., ref_unit=0x0) at src/terrain/filter.cpp:404
#9  0x0000555555de1ae8 in terrain_filter::match(map_location const&) const (this=0x7fff8f7fcba0, loc=...) at src/terrain/filter.hpp:42
#10 0x0000555555ef06e8 in unit_filter_impl::unit_filter_compound::<lambda(const vconfig&, const unit_filter_impl::unit_filter_args&)>::operator()(const vconfig &, const unit_filter_impl::unit_filter_args &) const
    (__closure=0x7fff73dce490, c=..., args=...) at src/units/filter.cpp:709
#11 0x0000555555f14bf9 in (anonymous namespace)::unit_filter_child_literal<unit_filter_impl::unit_filter_compound::fill(vconfig)::<lambda(const vconfig&, const unit_filter_impl::unit_filter_args&)> >::matches(const unit_filter_impl::unit_filter_args &) const (this=0x7fff73dce470, args=...) at src/units/filter.cpp:167
#12 0x0000555555eeca5a in unit_filter_impl::unit_filter_compound::filter_impl(unit_filter_impl::unit_filter_args const&) const (this=0x7fff8f7fd018, args=...) at src/units/filter.cpp:265
#13 0x0000555555eec74f in unit_filter_impl::unit_filter_compound::matches(unit_filter_impl::unit_filter_args const&) const (this=0x7fff8f7fd018, args=...) at src/units/filter.cpp:238
#14 0x0000555555de239c in unit_filter::matches(unit const&, map_location const&) const (this=0x7fff8f7fcff0, u=..., loc=...) at src/units/filter.hpp:135
#15 0x0000555555f62139 in unit::add_modification(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, config const&, bool) (this=0x7fff73daa730, mod_type="trait", mod=..., no_add=true)
    at src/units/unit.cpp:2153
#16 0x0000555555f637e0 in unit::apply_modifications() (this=0x7fff73daa730) at src/units/unit.cpp:2308
#17 0x0000555555f57d5b in unit::advance_to(unit_type const&, bool) (this=0x7fff73daa730, u_type=..., use_traits=true) at src/units/unit.cpp:982
#18 0x0000555555f53b0b in unit::init(config const&, bool, vconfig const*) (this=0x7fff73daa730, cfg=..., use_traits=true, vcfg=0x0) at src/units/unit.cpp:515
#19 0x0000555555de1bd1 in unit::create(config const&, bool, vconfig const*) (cfg=..., use_traits=true, vcfg=0x0) at src/units/unit.hpp:126
#20 0x00005555563ec46c in unit_creator::add_unit(config const&, vconfig const*) (this=0x7fff8f7fd910, cfg=..., vcfg=0x0) at src/actions/unit_creator.cpp:185
#21 0x00005555563d37cb in team_builder::place_units() (this=0x7fff797771f0) at src/teambuilder.cpp:287
#22 0x00005555563d23e0 in team_builder::build_team_stage_two() (this=0x7fff797771f0) at src/teambuilder.cpp:88
#23 0x00005555563d202e in build_team_stage_two(std::shared_ptr<team_builder>) (tb_ptr=std::shared_ptr<class team_builder> (use count 3, weak count 0) = {...}) at src/teambuilder.cpp:311
#24 0x000055555622bcdf in game_state::init(config const&, play_controller&) (this=0x7fff79038b70, level=..., pc=...) at src/game_state.cpp:220
#25 0x00005555563880b6 in play_controller::<lambda()>::operator()(void) const (__closure=0x7fffffffcc08) at src/play_controller.cpp:220
#26 0x000055555639102f in std::_Function_handler<void(), play_controller::init(const config&)::<lambda()> >::_M_invoke(const std::_Any_data &) (__functor=...) at /usr/include/c++/9/bits/std_function.h:300
#27 0x000055555587d7e4 in std::function<void ()>::operator()() const (this=0x7fffffffcc08) at /usr/include/c++/9/bits/std_function.h:688
#28 0x0000555555b89292 in gui2::dialogs::loading_screen::<lambda()>::operator()(void) const (__closure=0x55555a8060f8) at src/gui/dialogs/loading_screen.cpp:116
#29 0x0000555555b8ad8e in boost::detail::thread_data<gui2::dialogs::loading_screen::pre_show(gui2::window&)::<lambda()> >::run(void) (this=0x55555a805fc0) at /usr/include/boost/thread/detail/thread.hpp:120
#30 0x00007ffff7e5443b in  () at /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.71.0
#31 0x00007ffff7e78609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#32 0x00007ffff7145293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
@Pentarctagon Pentarctagon added Bug Issues involving unexpected behavior. Engine General game engine issues that do not fit in any other category. labels Mar 27, 2021
@MortredAi
Copy link

i have this bugs but i dont know how to fix it. can you tell me how to fix that?

@Pentarctagon
Copy link
Member Author

Either don't use or remove the add-on causing the error, or otherwise someone will need to implement a fix in the C++ engine code.

@MortredAi
Copy link

so there is a way to fix that by implement something?

@Pentarctagon
Copy link
Member Author

I'm not sure what you're asking.

@Deathdealer5555
Copy link

i can confirm that this crash happens even if the only addon being used is Enhanced Traits. friends of mine thinks it might just be a missing parentheses after the 'new' traits. like, the ones the mod adds in, so far i've confirmed that a unit having the Nocturnal trait causes it to crash, as well as either Wicked or Restless, possibly both.

@Deathdealer5555
Copy link

Deathdealer5555 commented Jun 3, 2021

Method of determining what causes the crash:
i've loaded 'Heir to the Throne', with no other addons, recruit an Elf Archer, see what traits it has, then save and load. if it crashes, one of those two traits might have caused it, if not, the traits don't cause it.
Traits that cause the Crash:
Nocturnal
Wicked
Righteous
Diurnal
Traits that might cause a Crash:
i think i've tested them all
Traits that do not cause a crash:
Strong
Dextrous
Urban
Rural
Relentless
Attentive
Energetic
Healthy
Wealthy
Treacherous
Sturdy
Resilient
Restless
Intelligent

@stevecotton
Copy link
Contributor

@Vultraz this looks like a bug in 6a21fdc to me - using a GUI-related singleton from classes that shouldn't need a GUI.

@Pentarctagon
Copy link
Member Author

Pentarctagon commented Nov 29, 2021

Would the solution be to just revert the non-editor-specific changes from that commit? Just from a glance it doesn't look like there's anything else really going on there.

stevecotton added a commit to stevecotton/wesnoth that referenced this issue Dec 30, 2022
…troller::init

Partially reverts 6a21fdc
Fixes wesnoth#5643
Fixes wesnoth#7238

There's a bunch of global things that can be accessed either via global
pointers in the `resource` namespace, or via `display::get_singleton()`. The
singleton and these global pointers are set up in `play_controller::init`,
however there's a section where things are available via the global pointers
but the `display` singleton doesn't exist yet. During that time, checking
whether an ability is active can crash the game.

Removing the global pointers is a good goal, but detouring through a GUI class
to access the data causes its own problems.

The "has already been confirmed valid by both callers" comment is replaced with
an assert, because there's currently at least three callers.
stevecotton added a commit that referenced this issue Dec 30, 2022
…troller::init

Partially reverts 6a21fdc
Fixes #5643
Fixes #7238

There's a bunch of global things that can be accessed either via global
pointers in the `resource` namespace, or via `display::get_singleton()`. The
singleton and these global pointers are set up in `play_controller::init`,
however there's a section where things are available via the global pointers
but the `display` singleton doesn't exist yet. During that time, checking
whether an ability is active can crash the game.

Removing the global pointers is a good goal, but detouring through a GUI class
to access the data causes its own problems.

The "has already been confirmed valid by both callers" comment is replaced with
an assert, because there's currently at least three callers.
stevecotton added a commit to stevecotton/wesnoth that referenced this issue Dec 30, 2022
…troller::init

Partially reverts 6a21fdc
Fixes wesnoth#5643
Fixes wesnoth#7238

There's a bunch of global things that can be accessed either via global
pointers in the `resource` namespace, or via `display::get_singleton()`. The
singleton and these global pointers are set up in `play_controller::init`,
however there's a section where things are available via the global pointers
but the `display` singleton doesn't exist yet. During that time, checking
whether an ability is active can crash the game.

Removing the global pointers is a good goal, but detouring through a GUI class
to access the data causes its own problems.

The "has already been confirmed valid by both callers" comment is replaced with
an assert, because there's currently at least three callers.

(cherry picked from commit 7ddf691)
stevecotton added a commit that referenced this issue Dec 31, 2022
…troller::init

Partially reverts 6a21fdc
Fixes #5643
Fixes #7238

There's a bunch of global things that can be accessed either via global
pointers in the `resource` namespace, or via `display::get_singleton()`. The
singleton and these global pointers are set up in `play_controller::init`,
however there's a section where things are available via the global pointers
but the `display` singleton doesn't exist yet. During that time, checking
whether an ability is active can crash the game.

Removing the global pointers is a good goal, but detouring through a GUI class
to access the data causes its own problems.

The "has already been confirmed valid by both callers" comment is replaced with
an assert, because there's currently at least three callers.

(cherry picked from commit 7ddf691)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues involving unexpected behavior. Engine General game engine issues that do not fit in any other category.
Projects
None yet
4 participants