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

Prevent segfault when deconstructing improvised shelter #75703

Merged
merged 1 commit into from
Aug 20, 2024

Conversation

inogenous
Copy link
Contributor

Summary

Bugfixes "Prevent segfault when deconstructing improvised shelter"

Purpose of change

Fixes #75525 .

Describe the solution

Previous segfault happened when trying to display the list of items that deconstruction would yield, but this terrain has no deconstruct json.

This commit also adds a check with debugmsg for future such cases during the game startup validation. It also fixes other terrains that had the same problem (t_improvised_shelter_filled, t_rockyobstacle and t_carpet_concrete_green_olight).

Previous crash being fixed:

Thread 1 "cataclysm-tiles" received signal SIGSEGV, Segmentation fault.
0x0000555555cb9602 in operator() (drop_group=..., __closure=<optimized out>) at src/construction.cpp:2049
2049                            item_group::spawn_data_from_group( drop_group )->every_item_min_max();
(gdb) bt
 #0  0x0000555555cb9602 in operator() (drop_group=..., __closure=<optimized out>) at src/construction.cpp:2049
 #1  0x0000555555cb9af2 in construct::do_turn_deconstruct (p=..., who=...) at src/construction.cpp:2086
 #2  0x0000555555a32fad in activity_handlers::build_do_turn (act=0x5555583e4338, you=0x5555583e3c70) at src/activity_handlers.cpp:3424
 #3  0x0000555555a6b7de in std::function<void(player_activity*, Character*)>::operator() (this=<optimized out>, __args#0=<optimized out>, __args#0@entry=0x5555583e4338, __args#1=<optimized out>, __args#1@entry=0x5555583e3c70) at /usr/include/c++/14/bits/std_function.h:591
 #4  0x0000555555a69647 in activity_type::call_do_turn (this=<optimized out>, act=act@entry=0x5555583e4338, you=you@entry=0x5555583e3c70) at src/activity_type.cpp:160
 #5  0x00005555566d3a1c in player_activity::do_turn (this=0x5555583e4338, you=...) at src/player_activity.cpp:320
 #6  0x0000555555dcef82 in do_turn () at src/do_turn.cpp:592
 #7  0x00005555557a1217 in main (argc=<optimized out>, argv=<optimized out>) at src/main.cpp:873

Describe alternatives you've considered

Considered just removing the EASY_DECONSTRUCT flag from the improvised shelters, but that would have been too easy.

Testing

Can no longer reproduce the segfault in #75525 . The improvised shelter can now be simple-deconstructed:

snapshot4
snapshot5

Additional context

@github-actions github-actions bot added [JSON] Changes (can be) made in JSON Crafting / Construction / Recipes Includes: Uncrafting / Disassembling [C++] Changes (can be) made in C++. Previously named `Code` Fields / Furniture / Terrain / Traps Objects that are part of the map or its features. <Bugfix> This is a fix for a bug (or closes open issue) json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Aug 15, 2024
Previous segfault happened when trying to display the list of items that
deconstruction would yield, but this terrain has no `deconstruct` json.

This commit also adds a check with `debugmsg` for future such cases
during the game startup validation.

Previous crash being fixed:
```
Thread 1 "cataclysm-tiles" received signal SIGSEGV, Segmentation fault.
0x0000555555cb9602 in operator() (drop_group=..., __closure=<optimized out>) at src/construction.cpp:2049
2049                            item_group::spawn_data_from_group( drop_group )->every_item_min_max();
(gdb) bt
 #0  0x0000555555cb9602 in operator() (drop_group=..., __closure=<optimized out>) at src/construction.cpp:2049
 CleverRaven#1  0x0000555555cb9af2 in construct::do_turn_deconstruct (p=..., who=...) at src/construction.cpp:2086
 CleverRaven#2  0x0000555555a32fad in activity_handlers::build_do_turn (act=0x5555583e4338, you=0x5555583e3c70) at src/activity_handlers.cpp:3424
 CleverRaven#3  0x0000555555a6b7de in std::function<void(player_activity*, Character*)>::operator() (this=<optimized out>, __args#0=<optimized out>, __args#0@entry=0x5555583e4338, __args#1=<optimized out>, __args#1@entry=0x5555583e3c70) at /usr/include/c++/14/bits/std_function.h:591
 CleverRaven#4  0x0000555555a69647 in activity_type::call_do_turn (this=<optimized out>, act=act@entry=0x5555583e4338, you=you@entry=0x5555583e3c70) at src/activity_type.cpp:160
 CleverRaven#5  0x00005555566d3a1c in player_activity::do_turn (this=0x5555583e4338, you=...) at src/player_activity.cpp:320
 CleverRaven#6  0x0000555555dcef82 in do_turn () at src/do_turn.cpp:592
 CleverRaven#7  0x00005555557a1217 in main (argc=<optimized out>, argv=<optimized out>) at src/main.cpp:873
```
@github-actions github-actions bot added Mods Issues related to mods or modding Mods: Xedra Evolved Anything to do with Xedra Evolved labels Aug 15, 2024
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Aug 19, 2024
@dseguin dseguin merged commit 4aee24f into CleverRaven:master Aug 20, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Crafting / Construction / Recipes Includes: Uncrafting / Disassembling Fields / Furniture / Terrain / Traps Objects that are part of the map or its features. [JSON] Changes (can be) made in JSON json-styled JSON lint passed, label assigned by github actions Mods: Xedra Evolved Anything to do with Xedra Evolved Mods Issues related to mods or modding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Desconstructing Improvised Shelter crashes game
2 participants