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

Backport 75310 to 0.H-branch #75691

Conversation

inogenous
Copy link
Contributor

@inogenous inogenous commented Aug 15, 2024

Summary

Bugfixes "Prevent segfault when target of firstaid_activity_actor disappears"

Purpose of change

Backport #75310 to 0.H-branch. Fixes #75689 .

Describe the solution

See #75310 for info.

Describe alternatives you've considered

Testing

Additional context

Prevents segfault when performing `firstaid_activity_actor` but the
bandage tool disappeared. Backtrace of fixed segfault:
```
Thread 1 "cataclysm-tiles" received signal SIGSEGV, Segmentation fault.
(gdb) bt
 #0  0x0000555555ece5a4 in item::get_usable_item_helper<item> (use_name="heal", self=...) at src/item.cpp:11584
 CleverRaven#1  item::get_usable_item (this=0x0, use_name="heal") at src/item.cpp:11606
 CleverRaven#2  0x000055555599c6bf in firstaid_activity_actor::finish (this=0x55559b583f20, act=..., who=...) at src/activity_actor.cpp:6651
 CleverRaven#3  0x00005555564d8c6b in player_activity::do_turn (this=0x555558108218, you=...) at src/player_activity.cpp:391
 CleverRaven#4  0x0000555555ce3fa6 in do_turn () at src/do_turn.cpp:532
 CleverRaven#5  0x000055555577511a in main (argc=<optimized out>, argv=<optimized out>) at src/main.cpp:873
```

An example where this happened was when the bandage was inside a
spillable container (clay canning pot), that spilled its contents when
starting the activity. Spiling the clay canning pot invalidates the
`item_location`. Backtrace of when the clay canning pot was spilled:
```
 #0  item_pocket::get_name (this=0x555557fa7540) at src/item_pocket.cpp:2117
 CleverRaven#1  item_pocket::handle_liquid_or_spill (this=this@entry=0x555557fa7540, guy=..., avoid=0x555557fa8060) at src/item_pocket.cpp:806
 CleverRaven#2  0x0000555555a6aa60 in avatar_action::use_item (you=..., loc=..., method="heal") at src/avatar_action.cpp:1212
 CleverRaven#3  0x0000555555a6dda7 in avatar_action::eat_or_use (you=..., loc=...) at src/avatar_action.cpp:988
 CleverRaven#4  0x0000555555e3e1c5 in game::do_regular_action (this=this@entry=0x555557f94a60, act=@0x7fffffffd1b0: ACTION_EAT, player_character=..., mouse_target=std::optional [no contained value]) at src/handle_action.cpp:2479
 CleverRaven#5  0x0000555555e41260 in game::handle_action (this=0x555557f94a60) at src/handle_action.cpp:3176
 CleverRaven#6  0x0000555555ce422f in do_turn () at /usr/include/c++/13/bits/unique_ptr.h:199
 CleverRaven#7  0x000055555577511a in main (argc=<optimized out>, argv=<optimized out>) at src/main.cpp:873
```
@inogenous inogenous changed the title Prevent segfault when target of firstaid_activity_actor disappears Backport 75310 to 0.H-branch Aug 15, 2024
@github-actions github-actions bot added <Bugfix> This is a fix for a bug (or closes open issue) <Enhancement / Feature> New features, or enhancements on existing Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Info / User Interface Game - player communication, menus, etc. [C++] Changes (can be) made in C++. Previously named `Code` astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions labels Aug 15, 2024
@akrieger akrieger merged commit 9883075 into CleverRaven:0.H-branch Aug 15, 2024
22 checks passed
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Aug 15, 2024
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` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style <Enhancement / Feature> New features, or enhancements on existing Info / User Interface Game - player communication, menus, etc. json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants