CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.61k stars 4.17k forks source link

Segmentation Fault Crash when opening inventory #41080

Closed DalenHealy closed 3 years ago

DalenHealy commented 4 years ago

Describe the bug

Game crashes, providing a segmentation fault error when trying to open inventory, activate items, or any activity that utilizes items in the players inventory. this began after picking up a shoulder strap.

Steps To Reproduce

open inventory or try to activate, throw, or reload an item (or any similar action involving the player's inventory)

Expected behavior

Game should not crash upon taking the stated action

Versions and configuration

Additional context

enaantd commented 4 years ago

I have a similar problem in my own game and did some investigation. In my case, if I unload a weapon that is in my inventory and then open the inventory, or if I unload a weapon to the ground and then examine the tile or list all items, I get a segfault.

I tried to reproduce in a test world but it didn't crash there, so I spawned a M4A1 in my world to compare it with my own. The difference is that only one of them has fouling:

Screenshot_2020-06-08_11-22-55

Hence, I think this is related to #41048: unloading a weapon that was obtained before this PR seems to produce a segfault.

EDIT: I did some more testing, and while I could fix the problem in my game by spawning new weapons from the debug menu (and destroying the old ones), this doesn't fix the shoulder strap problem.

I could however find the steps to reproduce:

miguel-swanson commented 4 years ago

I can confirm that weapon mods are "corrupting" guns when you save and reload. They appear to not have any attachments and segfault either when unloading or after unloading and opening the inventory.

wapcaplet commented 3 years ago

I could not reproduce this in 0.E-9737-g511ddcb179. I attached a couple gunmods to a Mosin-Nagant, saved and loaded, and the mods persisted with no errors viewing inventory. Many players use guns and gunmods all the time, and we would have certainly heard more reports of this bug in the last 8 months if it still existed.