forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 1
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
catchup to cleverraven #9
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Update evac_shelter.json * Update generic.json * Update data/json/itemgroups/SUS/evac_shelter.json Co-Authored-By: I-am-Erk <45136638+I-am-Erk@users.noreply.github.com> * Update evac_shelter.json * Update evac_shelter.json * Update evac_shelter.json * Update evac_shelter.json Co-authored-by: I-am-Erk <45136638+I-am-Erk@users.noreply.github.com>
fix furniture default max_volume
Overhaul map memory cache for tiles.
* Move internal computer methods out of header file * Remove instances of miss_launch * Skip loading of blacklisted computer options * Deprecate nuke launch enum * Kill nuke launch code.
Fix a memory leak in map::generate reported by LSAN in the CI build
Convert all C library includes to their C++ equivalents (stdio.h -> cstdio, etc.).
Enable this clang-tidy check.
* remove red sauce as substitute for chilly p and curry powder * add chili powder as substitute for curry powder Co-authored-by: I-am-Erk <45136638+I-am-Erk@users.noreply.github.com>
The role of the rock pot can largely be replaced by the clay pot, and it's recipe is largely nonsense.
* Added json-variant of HWS * Moved hadcoded varian to obsolete * Removed draw_sarcophagus function * Removed hardcoded overmap special * Added reminders for removal after 0.E.
Initialize tripoint to avoid always teleporting monsters to ground level
Update deprecated headers
M update json_info
Aluminum Chonk, Semiautomatic, 9mm statfixes
* Make beautiful mutations visible * Make ugly and pretty mutations visible * NPCs are people too
* Add missing shotgun modslots, remove duplicate grip on MCS * Capitalize your acronyms * Mechanisms
gettext does not recognize both strings in the original syntax. See "lang/po/cataclysm-dda.pot" - it does currently not contain the second string.
Fix extraction for translation
"info" and "default" are optional and ignored anyway.
* Adds 4-door Hatchback, renames old Hatchback to City Car * Adds car_hatch spawns at 50% car spawn rate, reduces car_mini spawns by 50% * Fixes car_hatch item group spawns. * Increase car_hatch fuel tank size to 40L (midpoint between city car and regular car)
Make JSON formatter conserve escape sequences
Replace characters in the Graphical Overmap mod with escape sequences
Fix token from %d to %s in color-related debug message
* autoswim * prompting and smarter choice
new tileset retrodays+
* Add triffid flower. * Add triffid flower to spawns.
Found by clang-tidy in the Travis tests for #36604.
There was a concern that the code didn't handle this case correctly, so added a test to allay that concern.
This text wasn't previously checked. Add ellipsis characters and spaces as appropriate.
Rather than a simple string, read these entries as translation objects. This has the advantage that they are checked for correct text styling.
Tweak timer to get eggs from chicken.
…logue Translations for mission dialogue
Make map::add_spawn() accept a tripoint instead of a point
Maleclypse
pushed a commit
that referenced
this pull request
May 11, 2020
The function `are_requirements_nearby` accesses `player::backlog::front()`, which causes UB when the `backlog` list is empty. This is usually checked by the caller, but there is at least one way to reach this function without that check: ``` #2 0x000000000083dfaa in string_id<activity_type>::operator== (rhs=..., this=0xdf1b460) at src/player_activity.h:93 #3 are_requirements_nearby (loot_spots=std::vector of length 21, capacity 32 = {...}, needed_things=..., p=..., activity_to_restore=..., in_loot_zones=true, src_loc=...) at src/activity_item_handling.cpp:1113 #4 0x0000000000843a46 in generic_multi_activity_check_requirement (p=..., act_id=..., act_info=..., src=..., src_loc=..., src_set=std::unordered_set with 1 element = {...}, check_only=false) at src/activity_item_handling.cpp:2676 #5 0x0000000000852813 in generic_multi_activity_handler (act=..., p=..., check_only=check_only@entry=false) at src/activity_item_handling.cpp:2885 #6 0x0000000000800896 in activity_handlers::multiple_butcher_do_turn (act=<optimized out>, p=<optimized out>) at src/activity_handlers.cpp:3822 #7 0x000000000082b248 in std::_Function_handler<void (player_activity*, player*), void (*)(player_activity*, player*)>::_M_invoke(std::_Any_data const&, player_activity*&&, player*&&) (__functor=..., __args#0=<optimized out>, __args#1=<optimized out>) at /usr/include/c++/8/bits/std_function.h:88 #8 0x00000000008630e3 in std::function<void (player_activity*, player*)>::operator()(player_activity*, player*) const (this=<optimized out>, __args#0=<optimized out>, __args#0@entry=0xdf1b330, __args#1=<optimized out>, __args#1@entry=0xdf1ae50) at /usr/include/c++/8/bits/std_function.h:260 #9 0x0000000000860306 in activity_type::call_do_turn (this=0x2c3c930, act=act@entry=0xdf1b330, p=p@entry=0xdf1ae50) at src/activity_type.cpp:118 #10 0x00000000014a968b in player_activity::do_turn (this=this@entry=0xdf1b330, p=...) at src/player_activity.cpp:237 #11 0x00000000013092a4 in npc::do_player_activity (this=this@entry=0xdf1ae50) at src/npcmove.cpp:3299 #12 0x0000000001322a07 in npc::execute_action (this=this@entry=0xdf1ae50, action=<optimized out>, action@entry=npc_player_activity) at src/npcmove.cpp:1237 #13 0x000000000132690a in npc::move (this=this@entry=0xdf1ae50) at src/npcmove.cpp:907 ``` This adds a simple check within the function.
Maleclypse
pushed a commit
that referenced
this pull request
May 23, 2020
Update furniture-medical.json
Maleclypse
pushed a commit
that referenced
this pull request
Nov 21, 2023
* Prevents game occasionally seemingly hanging when moving to new submaps The reason for the previous problem was an infinite loop caused by: 1. `map::spawn_monsters_submap` for-loops the list of `current_submap->spawns` 2. for every spawned monster, it calls `monster::on_load` 3. `monster::on_load` calls `monster::try_reproduce`, which in turn calls `map::add_spawn` 4. So a new spawn is added, thus invalidating the iterator used in step 1 5. Undefined behavior caused by using invaliated iterators. On my compiler (gcc 13.2.0), the above problem had the following effect: * The reference `spawn_point &i` pointed to something totally different, so that in particular, `i.count` had garbage values * Instead of `i.count` being reasonable values such as `3` or `1`, the above undefined behavior made it have values such as `925969776` or `-632214304` * `i.count` is the upper bound for the inner for-loop in `map::spawn_monsters_submap`, so depending on the garbage value, it might seem like an infinite loop. Stacktrace of app when frozen and problem happened: ``` #0 0x000055a1eaf36dcb in creature_tracker::find(coords::coord_point<tripoint, (coords::origin)1, (coords::scale)0> const&) const () #1 0x000055a1eaf39253 in Creature* creature_tracker::creature_at<Creature>(coords::coord_point<tripoint, (coords::origin)1, (coords::scale)0> const&, bool) () #2 0x000055a1eaf393b5 in Creature* creature_tracker::creature_at<Creature>(tripoint const&, bool) () #3 0x000055a1eb357a53 in map::spawn_monsters_submap(tripoint const&, bool, bool)::{lambda(tripoint const&)#1}::operator()(tripoint const&) const () #4 0x000055a1eb3a976e in random_point(tripoint_range<tripoint> const&, std::function<bool (tripoint const&)> const&) () #5 0x000055a1eb37dd2d in map::spawn_monsters_submap(tripoint const&, bool, bool) () #6 0x000055a1eb37de77 in map::spawn_monsters(bool, bool) () #7 0x000055a1eb093981 in game::update_map(int&, int&, bool) () #8 0x000055a1eb094451 in game::update_map(Character&, bool) () #9 0x000055a1eb09530f in game::place_player(tripoint const&, bool) () #10 0x000055a1eb0b3a0e in game::walk_move(tripoint const&, bool, bool) () #11 0x000055a1ead27490 in avatar_action::move(avatar&, map&, tripoint const&) () #12 0x000055a1eb0f338c in game::do_regular_action(action_id&, avatar&, std::optional<tripoint> const&) () #13 0x000055a1eb0f6e63 in game::handle_action() () #14 0x000055a1eafbd9ea in do_turn() () #15 0x000055a1eaa5ec13 in main () ``` This commit instead changes the loop in step 1 above so that it explicitly *not* uses iterators, but instead old-fashioned indexed loop. The intention with the change is to allow other parts of the code to add items to the vector `current_submap->spawns` while we are iterating it here. If new items are added, they will be handled in later steps of the loop.
Maleclypse
pushed a commit
that referenced
this pull request
Jan 2, 2024
Prevents segfault that previously happened when pouring liquid to ground from AIM using "examine" menu. Previous segfault being fixed: ``` #0 __gnu_cxx::__atomic_add_dispatch () at /usr/include/c++/13/ext/atomicity.h:111 #1 std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_add_ref_copy () at /usr/include/c++/13/bits/shared_ptr_base.h:152 #2 0x00005652b2df5540 in std::shared_ptr<item_location::impl>::shared_ptr () at /usr/include/c++/13/bits/shared_ptr.h:204 #3 item_location::item_location () at src/item_location.h:30 #4 item_location::impl::item_in_container::item_in_container () at src/item_location.cpp:612 #5 item_location::item_location () at src/item_location.cpp:767 #6 0x00005652b27fa6b1 in unload_activity_actor::unload () at src/activity_actor.cpp:3232 #7 0x00005652b32eed69 in player_activity::do_turn () at src/player_activity.cpp:383 #8 0x00005652b2b553e7 in do_turn () at src/do_turn.cpp:487 #9 0x00005652b25ea589 in main () at src/main.cpp:798 ``` The problem before was that the reference to `target` in `unload_activity_actor::unload` was an invalid reference. This was caused by: 1. `unload_activity_actor::finish` calls `act.set_to_null()`. 2. That sets the player activity to `null` type (=no current activity) 3. `unload_activity_actor::unload` is `static`, and takes `target` as a reference. 4. `::unload` calls `Character::add_or_drop_with_msg` which leads to call chain: `liquid_handler::consume_liquid` -> `get_liquid_target` -> `choose_adjacent` -> `choose_direction` -> `temp_hide_advanced_inv` -> `advanced_inventory::temp_hide` -> `advanced_inventory::do_return_entry` 5. `advanced_inventory::do_return_entry` assigns a new `ACT_ADV_INVENTORY` activity. This invalidates the previous `unload_activity_actor` because of pt 2 above. 6. When static method `unload_activity_actor::unload` resumes after its call to `add_or_drop_with_msg`, the reference to `target` is invalid because of pt 5. This commit attempt to fix the issue with invalidated `target` reference by copying its value before invalidating the activity.
Maleclypse
pushed a commit
that referenced
this pull request
Jan 9, 2024
* Add missing was_loaded initialization We forgot to initialize was_loaded in profession_group I found this bug thanks to UndefinedBehaviorSanitizer ```c++ src/profession_group.h:8:8: runtime error: load of value 60, which is not a valid value for type 'bool' #0 0x6fa4312 in profession_group::profession_group(profession_group const&) src/profession_group.h:8 #1 0x6fb241e in void std::__new_allocator<profession_group>::construct<profession_group, profession_group const&>(profession_group*, profession_group const&) /usr/include/c++/13/bits/new_allocator.h:187 #2 0x6fb241e in void std::allocator_traits<std::allocator<profession_group> >::construct<profession_group, profession_group const&>(std::allocator<profession_group>&, profession_group*, profession_group const&) /usr/include/c++/13/bits/alloc_traits.h:537 #3 0x6fb241e in void std::vector<profession_group, std::allocator<profession_group> >::_M_realloc_insert<profession_group const&>(__gnu_cxx::__normal_iterator<profession_group*, std::vector<profession_group, std::allocator<profession_group> > >, profession_group const&) /usr/include/c++/13/bits/vector.tcc:468 #4 0x6fb2911 in std::vector<profession_group, std::allocator<profession_group> >::push_back(profession_group const&) /usr/include/c++/13/bits/stl_vector.h:1289 #5 0x6fb2c14 in generic_factory<profession_group>::insert(profession_group const&) src/generic_factory.h:391 #6 0x6fb61a7 in generic_factory<profession_group>::load(JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) src/generic_factory.h:304 #7 0x6fa0efd in profession_group::load_profession_group(JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) src/profession_group.cpp:25 #8 0x4294940 in void std::__invoke_impl<void, void (*&)(JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&), JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&>(std::__invoke_other, void (*&)(JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&), JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /usr/include/c++/13/bits/invoke.h:61 #9 0x4294976 in std::enable_if<is_invocable_r_v<void, void (*&)(JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&), JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&>, void>::type std::__invoke_r<void, void (*&)(JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&), JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&>(void (*&)(JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&), JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /usr/include/c++/13/bits/invoke.h:111 #10 0x4294976 in std::_Function_handler<void (JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&), void (*)(JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)>::_M_invoke(std::_Any_data const&, JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /usr/include/c++/13/bits/std_function.h:290 #11 0x4290c79 in std::function<void (JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)>::operator()(JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const /usr/include/c++/13/bits/std_function.h:591 #12 0x426934f in operator() src/init.cpp:227 #13 0x426934f in __invoke_impl<void, DynamicDataLoader::add(const std::string&, const std::function<void(const JsonObject&, const std::__cxx11::basic_string<char>&)>&)::<lambda(const JsonObject&, const std::string&, const cata_path&, const cata_path&)>&, const JsonObject&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, const cata_path&, const cata_path&> /usr/include/c++/13/bits/invoke.h:61 #14 0x426934f in __invoke_r<void, DynamicDataLoader::add(const std::string&, const std::function<void(const JsonObject&, const std::__cxx11::basic_string<char>&)>&)::<lambda(const JsonObject&, const std::string&, const cata_path&, const cata_path&)>&, const JsonObject&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, const cata_path&, const cata_path&> /usr/include/c++/13/bits/invoke.h:111 #15 0x426934f in _M_invoke /usr/include/c++/13/bits/std_function.h:290 #16 0x42904f3 in std::function<void (JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cata_path const&, cata_path const&)>::operator()(JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cata_path const&, cata_path const&) const /usr/include/c++/13/bits/std_function.h:591 #17 0x4284949 in DynamicDataLoader::load_object(JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cata_path const&, cata_path const&) src/init.cpp:137 #18 0x4285c32 in DynamicDataLoader::load_all_from_json(JsonValue const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, loading_ui&, cata_path const&, cata_path const&) src/init.cpp:540 #19 0x4286744 in DynamicDataLoader::load_data_from_path(cata_path const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, loading_ui&) src/init.cpp:521 #20 0x3ca25fa in game::load_data_from_dir(cata_path const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, loading_ui&) src/game.cpp:571 #21 0x3d21130 in game::load_packs(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<string_id<MOD_INFORMATION>, std::allocator<string_id<MOD_INFORMATION> > > const&, loading_ui&) src/game.cpp:3265 #22 0x3d518b5 in game::load_world_modfiles(loading_ui&) src/game.cpp:3235 #23 0x3e055d0 in game::setup() src/game.cpp:756 #24 0x5111cc3 in main_menu::new_character_tab() src/main_menu.cpp:972 #25 0x5127aea in main_menu::opening_screen() src/main_menu.cpp:863 #26 0x50f1e5e in main src/main.cpp:792 #27 0x7f7a489cfb89 in __libc_start_call_main (/lib64/libc.so.6+0x27b89) (BuildId: f888be5f5e7d58e04cabb8c675c7ab94e77dd68c) #28 0x7f7a489cfc4a in __libc_start_main_alias_2 (/lib64/libc.so.6+0x27c4a) (BuildId: f888be5f5e7d58e04cabb8c675c7ab94e77dd68c) #29 0x1bec804 in _start (/home/cdda/git/Cataclysm-DDA/cataclysm-tiles+0x1bec804) (BuildId: 1a0225eb0946b150a1f9b1759d512b53fde7f1d0) ``` * Make overmap_terrain_coverage less likely to produce spurious errors * Revert "Make overmap_terrain_coverage less likely to produce spurious errors" This reverts commit 6134a08.
Maleclypse
pushed a commit
that referenced
this pull request
Jan 9, 2024
If melee_actori.is_grab is false grab.exclusive_grab and grab.respect_seatbelts were not initialized. This was causing errors under -fsanitize=undefined The solution initialize the booleans to value that match their defaults ```C++ src/mattack_actors.h:75:8: runtime error: load of value 190, which is not a valid value for type 'bool' #0 0x5a9b6fe in grab::grab(grab const&) src/mattack_actors.h:75 #1 0x5ab7635 in melee_actor::melee_actor(melee_actor const&) src/mattack_actors.h:106 #2 0x5ab8412 in std::__detail::_MakeUniq<melee_actor>::__single_object std::make_unique<melee_actor, melee_actor const&>(melee_actor const&) /usr/include/c++/13/bits/unique_ptr.h:1070 #3 0x5a87e4c in melee_actor::clone() const src/mattack_actors.cpp:962 #4 0x207632c in cata::clone_ptr<mattack_actor>::clone_ptr(cata::clone_ptr<mattack_actor> const&) src/clone_ptr.h:18 #5 0x6085941 in mtype_special_attack::mtype_special_attack(mtype_special_attack const&) src/mattack_common.h:47 #6 0x6085941 in std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack>::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack, true>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mtype_special_attack const&) /usr/include/c++/13/bits/stl_pair.h:559 #7 0x6085a2b in void std::__new_allocator<std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack> > >::construct<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mtype_special_attack const&>(std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack>*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mtype_special_attack const&) /usr/include/c++/13/bits/new_allocator.h:187 #8 0x6085a2b in void std::allocator_traits<std::allocator<std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack> > > >::construct<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mtype_special_attack const&>(std::allocator<std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack> > >&, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack>*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mtype_special_attack const&) /usr/include/c++/13/bits/alloc_traits.h:537 #9 0x6085a2b in void std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack>, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack> > >::_M_construct_node<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mtype_special_attack const&>(std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack> >*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mtype_special_attack const&) /usr/include/c++/13/bits/stl_tree.h:597 #10 0x6085b06 in std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack> >* std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack>, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack> > >::_M_create_node<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mtype_special_attack const&>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mtype_special_attack const&) /usr/include/c++/13/bits/stl_tree.h:614 #11 0x6085b71 in std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack>, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack> > >::_Auto_node::_Auto_node<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mtype_special_attack const&>(std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack>, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack> > >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mtype_special_attack const&) /usr/include/c++/13/bits/stl_tree.h:1637 #12 0x6085c9d in std::_Rb_tree_iterator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack> > std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack>, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack> > >::_M_emplace_hint_unique<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mtype_special_attack const&>(std::_Rb_tree_const_iterator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mtype_special_attack const&) /usr/include/c++/13/bits/stl_tree.h:2462 #13 0x608618f in std::_Rb_tree_iterator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack> > std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, mtype_special_attack, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack> > >::emplace_hint<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mtype_special_attack const&>(std::_Rb_tree_const_iterator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mtype_special_attack const&) /usr/include/c++/13/bits/stl_map.h:640 #14 0x608618f in std::pair<std::_Rb_tree_iterator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack> >, bool> std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, mtype_special_attack, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, mtype_special_attack> > >::emplace<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mtype_special_attack const&>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mtype_special_attack const&) /usr/include/c++/13/bits/stl_map.h:601 #15 0x5ff3881 in MonsterGenerator::add_attack(mtype_special_attack const&) src/monstergenerator.cpp:1312 #16 0x5ffafa5 in MonsterGenerator::load_monster_attack(JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) src/monstergenerator.cpp:1376 #17 0x4262e91 in operator() src/init.cpp:466 #18 0x4262e91 in __invoke_impl<void, DynamicDataLoader::initialize()::<lambda(const JsonObject&, const std::string&)>&, const JsonObject&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&> /usr/include/c++/13/bits/invoke.h:61 #19 0x4262e91 in __invoke_r<void, DynamicDataLoader::initialize()::<lambda(const JsonObject&, const std::string&)>&, const JsonObject&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&> /usr/include/c++/13/bits/invoke.h:111 #20 0x4262e91 in _M_invoke /usr/include/c++/13/bits/std_function.h:290 #21 0x4290ce9 in std::function<void (JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)>::operator()(JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const /usr/include/c++/13/bits/std_function.h:591 #22 0x42693bf in operator() src/init.cpp:227 #23 0x42693bf in __invoke_impl<void, DynamicDataLoader::add(const std::string&, const std::function<void(const JsonObject&, const std::__cxx11::basic_string<char>&)>&)::<lambda(const JsonObject&, const std::string&, const cata_path&, const cata_path&)>&, const JsonObject&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, const cata_path&, const cata_path&> /usr/include/c++/13/bits/invoke.h:61 #24 0x42693bf in __invoke_r<void, DynamicDataLoader::add(const std::string&, const std::function<void(const JsonObject&, const std::__cxx11::basic_string<char>&)>&)::<lambda(const JsonObject&, const std::string&, const cata_path&, const cata_path&)>&, const JsonObject&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, const cata_path&, const cata_path&> /usr/include/c++/13/bits/invoke.h:111 #25 0x42693bf in _M_invoke /usr/include/c++/13/bits/std_function.h:290 #26 0x4290563 in std::function<void (JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cata_path const&, cata_path const&)>::operator()(JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cata_path const&, cata_path const&) const /usr/include/c++/13/bits/std_function.h:591 #27 0x42849b9 in DynamicDataLoader::load_object(JsonObject const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cata_path const&, cata_path const&) src/init.cpp:137 #28 0x4285ca2 in DynamicDataLoader::load_all_from_json(JsonValue const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, loading_ui&, cata_path const&, cata_path const&) src/init.cpp:540 #29 0x42867b4 in DynamicDataLoader::load_data_from_path(cata_path const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, loading_ui&) src/init.cpp:521 #30 0x3ca266a in game::load_data_from_dir(cata_path const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, loading_ui&) src/game.cpp:571 #31 0x3d211a0 in game::load_packs(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<string_id<MOD_INFORMATION>, std::allocator<string_id<MOD_INFORMATION> > > const&, loading_ui&) src/game.cpp:3265 #32 0x3d51925 in game::load_world_modfiles(loading_ui&) src/game.cpp:3235 #33 0x3e05640 in game::setup() src/game.cpp:756 #34 0x5111d33 in main_menu::new_character_tab() src/main_menu.cpp:972 #35 0x5127b5a in main_menu::opening_screen() src/main_menu.cpp:863 #36 0x50f1ece in main src/main.cpp:792 #37 0x7fdc43fa9b89 in __libc_start_call_main (/lib64/libc.so.6+0x27b89) (BuildId: f888be5f5e7d58e04cabb8c675c7ab94e77dd68c) #38 0x7fdc43fa9c4a in __libc_start_main_alias_2 (/lib64/libc.so.6+0x27c4a) (BuildId: f888be5f5e7d58e04cabb8c675c7ab94e77dd68c) #39 0x1bec874 in _start (/home/cdda/git/Cataclysm-DDA/cataclysm-tiles+0x1bec874) (BuildId: be24990d1723c8da00f3e8701793ab983cf64dcc) ```
Maleclypse
pushed a commit
that referenced
this pull request
Aug 19, 2024
Prevents division by zero crash when displaying widgets with defined break levels. Example of where previous crash from div-by-zero happened: * Provided save used the `zenfs_thick_sidebar`, which includes widget `zenfs_mana_bar_14_no_label` that defines break levels. * When running the provided save, mana value is usually at `v=201` with `min=0` `max=201`. * Those values are computed by `known_magic::max_mana` where internal values are `bionic_penalty=999` `mana_base=1000` `int_bonus=200`. * But when int falls (because of tiredness), then `known_magic::max_mana` will return `0` because `int_bonus=-100`. * This leads to `_var_max=0` in `widget::value_color` and thus `var_range=0` which causes the div by zero. Backtrace of previous crash beng fixed: ``` Thread 1 "cataclysm-tiles" received signal SIGFPE, Arithmetic exception. 0x0000555556a9c54e in widget::value_color (this=this@entry=0x7fffffffb8d8, value=value@entry=201) at src/widget.cpp:1310 1310 const int value_offset = ( 100 * ( value - _var_min ) ) / var_range; (gdb) bt #0 0x0000555556a9c54e in widget::value_color (this=this@entry=0x7fffffffb8d8, value=value@entry=201) at src/widget.cpp:1310 #1 0x0000555556aa37dc in widget::color_value_string[abi:cxx11](int, int) (this=this@entry=0x7fffffffb8d8, value=201, width_max=width_max@entry=14) at src/widget.cpp:1262 #2 0x0000555556aa38ca in widget::show[abi:cxx11](avatar const&, unsigned int) (this=this@entry=0x7fffffffb8d8, ava=..., max_width=max_width@entry=14) at src/widget.cpp:890 #3 0x0000555556aa497f in widget::layout[abi:cxx11](avatar const&, unsigned int, int, bool) (this=this@entry=0x7fffffffb8d8, ava=..., max_width=<optimized out>, label_width=label_width@entry=0, skip_pad=false) at src/widget.cpp:1834 #4 0x0000555556aa42c2 in widget::layout[abi:cxx11](avatar const&, unsigned int, int, bool) (this=this@entry=0x7fffffffbe88, ava=..., max_width=<optimized out>, label_width=label_width@entry=9, skip_pad=false) at src/widget.cpp:1794 #5 0x0000555556aa3cfa in widget::layout[abi:cxx11](avatar const&, unsigned int, int, bool) (this=this@entry=0x7fffffffc438, ava=..., max_width=<optimized out>, label_width=label_width@entry=0, skip_pad=false) at src/widget.cpp:1724 #6 0x0000555556aa42c2 in widget::layout[abi:cxx11](avatar const&, unsigned int, int, bool) (this=this@entry=0x7fffffffc9e8, ava=..., max_width=<optimized out>, label_width=label_width@entry=0, skip_pad=false) at src/widget.cpp:1794 #7 0x0000555556aa42c2 in widget::layout[abi:cxx11](avatar const&, unsigned int, int, bool) (this=this@entry=0x555562c47160, ava=..., max_width=<optimized out>, max_width@entry=64, label_width=<optimized out>, skip_pad=skip_pad@entry=false) at src/widget.cpp:1794 #8 0x0000555556aa5222 in custom_draw_func (args=...) at src/widget.cpp:970 #9 0x0000555555ec4360 in std::function<int(draw_args const&)>::operator() (this=0x555597eb1780, __args#0=...) at /usr/include/c++/14/bits/std_function.h:591 #10 game::draw_panels (this=this@entry=0x55555827ef50, force_draw=force_draw@entry=true) at src/game.cpp:4007 #11 0x0000555555eed1ac in game::draw (this=0x55555827ef50, ui=...) at src/game.cpp:3961 #12 0x00005555569a962c in ui_adaptor::redraw_invalidated () at src/ui_manager.cpp:440 #13 0x00005555569a96e9 in ui_adaptor::redraw () at src/ui_manager.cpp:345 #14 0x00005555569a9710 in ui_manager::redraw () at src/ui_manager.cpp:506 #15 0x0000555555dd0850 in do_turn () at src/do_turn.cpp:712 #16 0x00005555557a138d in main (argc=<optimized out>, argv=<optimized out>) at src/main.cpp:873 (gdb) print var_range $1 = 0 (gdb) print value $2 = 201 (gdb) print _var_min $3 = 0 (gdb) print _var_max $4 = 0 ```
Maleclypse
pushed a commit
that referenced
this pull request
Aug 19, 2024
Prevents the crash listed below that previously happened when searching for zones to add, but the search yielded no results: ``` Thread 1 "cataclysm-tiles" received signal SIGABRT, Aborted. __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44 (gdb) bt #0 __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44 #1 0x00007ffff787840f in __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78 #2 0x00007ffff78294f2 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 #3 0x00007ffff78124ed in __GI_abort () at ./stdlib/abort.c:79 #4 0x00007ffff7ad501e in std::__glibcxx_assert_fail(char const*, int, char const*, char const*) () from /lib/x86_64-linux-gnu/libstdc++.so.6 #5 0x0000555555de2639 in std::vector<uilist_entry, std::allocator<uilist_entry> >::operator[] (this=<optimized out>, __n=<optimized out>) at /usr/include/c++/14/bits/stl_vector.h:1130 #6 std::vector<uilist_entry, std::allocator<uilist_entry> >::operator[] (this=<optimized out>, __n=<optimized out>) at /usr/include/c++/14/bits/stl_vector.h:1128 #7 0x000055555699deac in uilist_impl::draw_controls (this=0x555599a181d0) at src/ui.cpp:138 #8 0x0000555555b7c312 in cataimgui::window::draw (this=0x555599a181d0) at src/cata_imgui.cpp:631 #9 cataimgui::window::draw (this=0x555599a181d0) at src/cata_imgui.cpp:600 #10 0x00005555569a2b1c in ui_adaptor::redraw_invalidated () at src/ui_manager.cpp:440 #11 0x00005555569a2bd9 in ui_adaptor::redraw () at src/ui_manager.cpp:345 #12 0x00005555569a2c00 in ui_manager::redraw () at src/ui_manager.cpp:508 #13 0x000055555699bfa4 in uilist::inputfilter (this=this@entry=0x7fffffffb9c8) at src/ui.cpp:531 #14 0x000055555699ead4 in uilist::query (this=this@entry=0x7fffffffb9c8, loop=loop@entry=true, timeout=timeout@entry=-1, allow_unfiltered_hotkeys=allow_unfiltered_hotkeys@entry=false) at src/ui.cpp:865 #15 0x0000555555c610d4 in zone_manager::query_type (this=this@entry=0x555557274060 <zone_manager::get_manager()::manager>, personal=personal@entry=false) at src/clzones.cpp:621 #16 0x0000555555ef3894 in game::zones_manager (this=this@entry=0x555558291db0) at src/game.cpp:6944 #17 0x0000555555f5d279 in game::do_regular_action (this=this@entry=0x555558291db0, act=@0x7fffffffcfec: ACTION_ZONES, player_character=..., mouse_target=std::optional [no contained value]) at src/handle_action.cpp:2438 #18 0x0000555555f60769 in game::handle_action (this=0x555558291db0) at src/handle_action.cpp:3172 #19 0x0000555555dcf14d in do_turn () at src/do_turn.cpp:579 #20 0x00005555557a1217 in main (argc=<optimized out>, argv=<optimized out>) at src/main.cpp:873 ``` gdb shows that `parent.selected` was negative: ``` (gdb) frame 7 138 parent.entries[parent.selected].desc.c_str() (gdb) print parent.selected $1 = -1 (gdb) print parent.entries.size() $2 = 63 ```
Maleclypse
pushed a commit
that referenced
this pull request
Aug 19, 2024
Prevents crashes that previously happened from using references to `explosion_data` that had been invalidated. The problem before happened when killing "unfolded impossibility" in LIXA facility with a grenade, since this monster runs an eoc that switches maps. That led to `explosion_handler::process_explosions` being called twice recursively. First invocation iterates references, and the second invocation might append to the vector, and most certaily will clear the vector, thus invalidating references for the first invocation. Example crash being fixed by this commit, notice how `explosion_handler::process_explosions` occurs twice in the callstack: ``` Thread 1 "cataclysm-tiles" received signal SIGABRT, Aborted. __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44 (gdb) bt #0 __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44 #1 0x00007ffff787840f in __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78 #2 0x00007ffff78294f2 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 #3 0x00007ffff78124ed in __GI_abort () at ./stdlib/abort.c:79 #4 0x00007ffff7ad501e in std::__glibcxx_assert_fail(char const*, int, char const*, char const*) () from /lib/x86_64-linux-gnu/libstdc++.so.6 #5 0x000055555688b471 in std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*> >::operator[] (this=<optimized out>, __n=1967424379) at /usr/include/c++/14/bits/stl_vector.h:1128 #6 std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*> >::operator[] (this=<optimized out>, __n=1967424379) at /usr/include/c++/14/bits/stl_vector.h:1128 #7 string_identity_static::get_interned_string[abi:cxx11](int) (id=1967424379) at src/string_id.cpp:51 #8 0x0000555555fffed7 in string_identity_static::str[abi:cxx11]() const (this=<optimized out>) at src/string_id.h:140 #9 0x0000555556057423 in string_id<itype>::c_str (this=this@entry=0x5555a126a718) at src/string_id.h:253 #10 0x00005555560be56a in Item_factory::find_template (this=0x55555751cad0, id=...) at src/item_factory.cpp:2563 #11 0x0000555555e4b0c5 in explosion_handler::_make_explosion (source=<optimized out>, p=..., ex=...) at /usr/include/c++/14/bits/unique_ptr.h:193 #12 0x0000555555e4b704 in explosion_handler::process_explosions () at src/explosion.cpp:923 #13 0x0000555556246e97 in map::actualize (this=this@entry=0x5555a12bf890, grid=...) at src/map.cpp:9168 #14 0x00005555562472c0 in map::load (this=this@entry=0x5555a12bf890, w=..., update_vehicle=update_vehicle@entry=true, pump_events=pump_events@entry=false) at src/map.cpp:8387 #15 0x0000555555de2546 in tinymap::load (this=this@entry=0x5555a12bf890, w=..., update_vehicles=update_vehicles@entry=true, pump_events=pump_events@entry=false) at src/map.h:2765 #16 0x00005555562a7e6f in update_mapgen_function_json::update_map (this=0x55555a8ce8f0, omt_pos=..., args=..., offset=..., miss=miss@entry=0x0, verify=verify@entry=true, mirror_horizontal=false, mirror_vertical=false, rotation=0) at src/mapgen.cpp:8015 #17 0x00005555562a81e3 in run_mapgen_update_func (update_mapgen_id=..., omt_pos=..., args=..., miss=miss@entry=0x0, cancel_on_collision=cancel_on_collision@entry=true, mirror_horizontal=mirror_horizontal@entry=false, mirror_vertical=false, rotation=0) at src/mapgen.cpp:8117 #18 0x00005555565a0250 in operator() (__closure=<optimized out>, d=...) at src/npctalk.cpp:3964 #19 0x000055555659c7a4 in talk_effect_t::apply (this=this@entry=0x55555d5211d8, d=...) at src/npctalk.cpp:6526 #20 0x0000555555e0c9ba in effect_on_condition::activate (this=0x55555d521160, d=..., require_callstack_check=require_callstack_check@entry=true) at src/effect_on_condition.cpp:329 #21 0x00005555561f9693 in spell_effect::effect_on_condition (sp=..., caster=..., target=...) at src/magic_spell_effect.cpp:1806 #22 0x00005555561d101e in spell::cast_all_effects (this=0x7fffffffc788, source=..., target=...) at src/magic.cpp:1907 #23 0x0000555556463bec in monster::die (this=0x55559c7fc0a0, nkiller=0x0) at src/monster.cpp:2941 #24 0x0000555555d33386 in Creature::deal_projectile_attack (this=0x55559c7fc0a0, source=0x0, attack=..., print_messages=<optimized out>, wp_attack=...) at src/creature.cpp:1311 #25 0x0000555556465049 in monster::deal_projectile_attack (this=this@entry=0x55559c7fc0a0, source=source@entry=0x0, attack=..., print_messages=print_messages@entry=false, wp_attack=...) at src/monster.cpp:2212 #26 0x0000555555e4a9d9 in explosion_handler::shrapnel (range=-1, source=<optimized out>, src=..., power=<optimized out>, casing_mass=<optimized out>, per_fragment_mass=<optimized out>) at src/explosion.cpp:463 #27 explosion_handler::_make_explosion (source=<optimized out>, p=..., ex=...) at src/explosion.cpp:536 #28 0x0000555555e4b704 in explosion_handler::process_explosions () at src/explosion.cpp:923 #29 0x0000555555dcf46f in do_turn () at src/do_turn.cpp:648 #30 0x00005555557a1227 in main (argc=<optimized out>, argv=<optimized out>) at src/main.cpp:873 ``` In the crash above, the `explosion_data` has been invalidated: ``` (gdb) frame 11 193 pointer _M_ptr() const noexcept { return std::get<0>(_M_t); } (gdb) print ex $1 = (const explosion_data &) @0x5555a126a6f8: {power = 1.75295132e+25, distance_factor = 2.76847299e+20, max_noise = 1667855474, fire = 117, shrapnel = {casing_mass = 1936026889, fragment_mass = 6.82915174e+22, recovery = -1584519120, drop = {_version = 13059389229367304, _cid = 2019155690, _id = { _id = 1967424379}}}} (gdb) print ex.shrapnel.drop $2 = {_version = 13059389229367304, _cid = 2019155690, _id = {_id = 1967424379}} ```
Maleclypse
pushed a commit
that referenced
this pull request
Aug 21, 2024
…aven#75521) Prevents referencing `visibility_cache` using out-of-bounds array indexes such as negative values. Using out-of-bound indexes for this array previously caused crashes when compiled with `-D_GLIBCXX_ASSERTIONS`. The function `pixel_minimap::render_critters` is, for example, called with `center=(64,59,-5)`, which gives `start=(4,-1)` and then `p=(4,-1,-5)`, which previously crashed because `visibility_cache[p.x][p.y]` then gives a negative array index. Such values were seen when peeking using `X` at a submap boundary. Gdb backtrace of previous crash being fixed: ``` (gdb) bt #0 __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44 #1 0x00007ffff787840f in __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78 #2 0x00007ffff78294f2 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 #3 0x00007ffff78124ed in __GI_abort () at ./stdlib/abort.c:79 #4 0x00007ffff7ad30be in std::__glibcxx_assert_fail(char const*, int, char const*, char const*) () from /lib/x86_64-linux-gnu/libstdc++.so.6 #5 0x000055555668a04e in std::array<lit_level, 132ul>::operator[] (__n=18446744073709551615, this=0x555599f30348) at /usr/include/c++/13/array:211 #6 0x000055555668ab7a in std::array<lit_level, 132ul>::operator[] (__n=18446744073709551615, this=0x555599f30348) at /usr/include/c++/13/array:211 #7 pixel_minimap::render_critters (this=this@entry=0x555558108960, center=...) at src/pixel_minimap.cpp:521 #8 0x000055555668ada2 in pixel_minimap::render (this=0x555558108960, center=...) at src/pixel_minimap.cpp:447 #9 0x000055555668bb69 in pixel_minimap::draw (this=<optimized out>, screen_rect=..., center=...) at src/pixel_minimap.cpp:555 #10 0x0000555555b3fd5c in cata_tiles::draw_minimap (this=this@entry=0x555558093020, dest=..., center=..., width=width@entry=352, height=height@entry=352) at src/cata_tiles.cpp:1919 #11 0x00005555567f43d3 in cata_cursesport::curses_drawwindow (w=...) at src/sdltiles.cpp:1428 #12 0x000055555666f5e2 in std::function<void(draw_args const&)>::operator() (__args#0=..., this=<optimized out>) at /usr/include/c++/13/bits/std_function.h:591 #13 operator() (d=..., __closure=<optimized out>) at src/panels.cpp:54 #14 std::__invoke_impl<int, window_panel::window_panel(const std::function<void(const draw_args&)>&, const std::string&, const translation&, int, int, bool, const std::function<bool()>&, bool)::<lambda(const draw_args&)>&, const draw_args&> (__f=...) at /usr/include/c++/13/bits/invoke.h:61 #15 std::__invoke_r<int, window_panel::window_panel(const std::function<void(const draw_args&)>&, const std::string&, const translation&, int, int, bool, const std::function<bool()>&, bool)::<lambda(const draw_args&)>&, const draw_args&> (__fn=...) at /usr/include/c++/13/bits/invoke.h:114 #16 std::_Function_handler<int(const draw_args&), window_panel::window_panel(const std::function<void(const draw_args&)>&, const std::string&, const translation&, int, int, bool, const std::function<bool()>&, bool)::<lambda(const draw_args&)> >::_M_invoke(const std::_Any_data &, const draw_args &) (__functor=..., __args#0=...) at /usr/include/c++/13/bits/std_function.h:290 #17 0x0000555555e7c9ec in std::function<int(draw_args const&)>::operator() (__args#0=..., this=0x55559461d638) at /usr/include/c++/13/bits/std_function.h:591 #18 game::draw_panels (this=this@entry=0x555558276c40, force_draw=force_draw@entry=true) at src/game.cpp:4006 #19 0x0000555555e984f8 in game::draw (this=0x555558276c40, ui=...) at src/game.cpp:3960 #20 0x000055555695df35 in ui_adaptor::redraw_invalidated () at src/ui_manager.cpp:440 #21 0x000055555695e039 in ui_adaptor::redraw () at src/ui_manager.cpp:345 #22 0x000055555695e060 in ui_manager::redraw () at src/ui_manager.cpp:506 #23 0x0000555555ea95cf in game::look_around (this=this@entry=0x555558276c40, show_window=show_window@entry=true, center=..., start_point=..., has_first_point=has_first_point@entry=false, select_zone=false, peeking=true, is_moving_zone=<optimized out>, end_point=..., change_lv=true) at src/game.cpp:7529 #24 0x0000555555eadd32 in game::look_around (this=this@entry=0x555558276c40, looka_params=...) at src/game.cpp:7697 #25 0x0000555555eadecb in game::peek (this=this@entry=0x555558276c40, p=...) at src/game.cpp:6071 #26 0x0000555555ec441a in game::peek (this=this@entry=0x555558276c40) at src/game.cpp:6050 #27 0x0000555555f124ec in game::do_regular_action (this=this@entry=0x555558276c40, act=@0x7fffffffd104: ACTION_PEEK, player_character=..., mouse_target=std::optional [no contained value]) at src/handle_action.cpp:2432 #28 0x0000555555f15b09 in game::handle_action (this=0x555558276c40) at src/handle_action.cpp:3174 #29 0x0000555555d8a108 in do_turn () at /usr/include/c++/13/bits/unique_ptr.h:199 #30 0x0000555555781b4e in main (argc=<optimized out>, argv=<optimized out>) at src/main.cpp:873 (gdb) frame 7 (gdb) print p $1 = {static dimension = 3, x = 4, y = -1, z = -5} (gdb) print center $2 = (const tripoint &) @0x7fffffffbda8: {static dimension = 3, x = 64, y = 59, z = -5} ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Purpose of change
Describe the solution
Describe alternatives you've considered
Testing
Additional context