Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Cataclysm can segfault when interrupted butchering is resumed #26113
Describe the bug
Cataclysm can segfault when butchering is interrupted, then resumed. The problem, as I recall, is that Cataclysm records the index of the corpse being butchered. However, this index is not guaranteed to remain valid from the time that the butchering is interrupted to the time that the butchering is resumed; other items can wind up in the grid square, potentially causing the index to refer to a non-corpse item. The invalid index can be saved with the character and the crash will persist across invocations of Cataclysm.
I tend to see this when butchering a corpse, being interrupted by a monster nearing, backing off the corpse, killing the monster on the same grid square, walking forward to try to resume butchering and having the game crash.
While I have not tested to confirm this, I suspect that, additionally, if an index is saved in the character's save file and there are multiple characters being played in the game world, that if one character is interrupted, has his game saved, another player is played in the world and mutates it, then it may similarly invalidate the index of the interrupted action.
Given the latter multiple-character situation, if resumable butchering is to be retained and done properly, it might be necessary to attach a UUID to each item (or at least each item referenced by a player's save file), something that would permit player references to items in the world to remain valid while the world mutates. Given that this would change the world save format, I'd imagine that it warrants developer discussion.
Versions and configuration(please complete the following information):
I think this is the activity being resumed in the save:
I couldn't understand the entire process, but I've noticed the following when going through the code with gdb: