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 if repair item disappears #75413

Merged

Conversation

inogenous
Copy link
Contributor

Summary

Bugfixes "Prevent segfault if repair item disappears"

Purpose of change

Prevents segfault that could previously occur if the item being repaired was invalidated. Fixes #75113 .

Describe the solution

The target item being repaired could get invalidated for various reasons, such as a follower moving it via zone sorting, the item could burn up in a fire, etc.

Previous segfault that this commit attempts to prevent:

 #0  0x0000555555ef9057 in item::is_null (this=this@entry=0x0) at src/item.cpp:943
 #1  0x000055555602322c in repair_item_actor::can_repair_target (this=this@entry=0x555560003e80, pl=..., fix=..., print_msg=print_msg@entry=true, check_consumed_available=check_consumed_available@entry=true) at src/iuse_actor.cpp:2920
 #2  0x00005555560243c2 in repair_item_actor::repair (this=this@entry=0x555560003e80, pl=..., tool=..., fix=..., refit_only=refit_only@entry=false) at src/iuse_actor.cpp:3106
 #3  0x00005555559d5b55 in repair_item_finish (act=0x5555580cdf58, you=0x5555580cd890, no_menu=false) at src/activity_handlers.cpp:2477
 #4  0x0000555555a00f52 in std::function<void (player_activity*, Character*)>::operator()(player_activity*, Character*) const (this=<optimized out>, __args#0=<optimized out>, __args#0@entry=0x5555580cdf58, __args#1=<optimized out>, __args#1@entry=0x5555580cd890) at /usr/include/c++/13/bits/std_function.h:591
 #5  0x00005555559ff229 in activity_type::call_finish (this=<optimized out>, act=act@entry=0x5555580cdf58, you=you@entry=0x5555580cd890) at src/activity_type.cpp:168
 #6  0x00005555564e368b in player_activity::do_turn (this=0x5555580cdf58, you=...) at src/player_activity.cpp:393
 #7  0x0000555555cec856 in do_turn () at src/do_turn.cpp:532
 #8  0x0000555555776e74 in main (argc=<optimized out>, argv=<optimized out>) at src/main.cpp:873

Instead, this commit adds a message shown to the player if the target item is no longer valid for whatever reason.

Describe alternatives you've considered

Testing

Performed the steps in #75113 . Can no longer reproduce the segfault on this branch. Instead, the new msg is shown:
snapshot2

Additional context

Prevents segfault that could previously occur if the item being repaired
was invalidated. The target item being repaired could get invalidated
for various reasons, such as a follower moving it via zone sorting, the
item could burn up in a fire, etc.

Previous segfault that this commit attempts to prevent:
```
 #0  0x0000555555ef9057 in item::is_null (this=this@entry=0x0) at src/item.cpp:943
 CleverRaven#1  0x000055555602322c in repair_item_actor::can_repair_target (this=this@entry=0x555560003e80, pl=..., fix=..., print_msg=print_msg@entry=true, check_consumed_available=check_consumed_available@entry=true) at src/iuse_actor.cpp:2920
 CleverRaven#2  0x00005555560243c2 in repair_item_actor::repair (this=this@entry=0x555560003e80, pl=..., tool=..., fix=..., refit_only=refit_only@entry=false) at src/iuse_actor.cpp:3106
 CleverRaven#3  0x00005555559d5b55 in repair_item_finish (act=0x5555580cdf58, you=0x5555580cd890, no_menu=false) at src/activity_handlers.cpp:2477
 CleverRaven#4  0x0000555555a00f52 in std::function<void (player_activity*, Character*)>::operator()(player_activity*, Character*) const (this=<optimized out>, __args#0=<optimized out>, __args#0@entry=0x5555580cdf58, __args#1=<optimized out>, __args#1@entry=0x5555580cd890) at /usr/include/c++/13/bits/std_function.h:591
 CleverRaven#5  0x00005555559ff229 in activity_type::call_finish (this=<optimized out>, act=act@entry=0x5555580cdf58, you=you@entry=0x5555580cd890) at src/activity_type.cpp:168
 CleverRaven#6  0x00005555564e368b in player_activity::do_turn (this=0x5555580cdf58, you=...) at src/player_activity.cpp:393
 CleverRaven#7  0x0000555555cec856 in do_turn () at src/do_turn.cpp:532
 CleverRaven#8  0x0000555555776e74 in main (argc=<optimized out>, argv=<optimized out>) at src/main.cpp:873
```

Instead, this commit adds a message shown to the player if the target
item is no longer valid for whatever reason.
@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` <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 BasicBuildPassed This PR builds correctly, label assigned by github actions labels Aug 3, 2024
@Maleclypse Maleclypse merged commit 6dc7f63 into CleverRaven:master Aug 4, 2024
23 of 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` json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Repairing neoprene arm sleeves segfault
2 participants