-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Invalid enum load in monster::store #36813
Comments
I figured out why bad enum value is not saved Cataclysm-DDA/src/savegame_json.cpp Lines 1973 to 1975 in 397d11e
|
This error might be caused by an uninitialized memory read. Line 538 in 397d11e
or in monster::monster() Lines 185 to 245 in 397d11e
According to https://github.com/CleverRaven/Cataclysm-DDA/search?q=horde_attraction&unscoped_q=horde_attraction horde_attraction is only assigned to Cataclysm-DDA/src/savegame_json.cpp Line 1901 in 6674292
in monster::get_horde_attraction(), but not before it is read, which means it should be initialized before calling get_horde_attraction() Lines 2839 to 2845 in 605409a
and in monster::set_horde_attraction() Lines 2847 to 2850 in 605409a
According to https://github.com/CleverRaven/Cataclysm-DDA/search?q=set_horde_attraction&unscoped_q=set_horde_attraction set_horde_attraction is only invoked in one place: when a monster stops being part of a horde. Lines 7175 to 7178 in 397d11e
Apparently when loading a saved monster the default is 0 (MHA_NULL), which get_horde_attraction later replaces with a random value (see above) Cataclysm-DDA/src/savegame_json.cpp Line 1901 in 6674292
|
Describe the bug
Steps To Reproduce
Steps to reproduce the behavior:
Note: this is not 100% reliable, but triggers most of the time for me.
Expected behavior
UBSan does not report the error.
Versions and configuration
Dark Days Ahead [dda],
Disable NPC Needs [no_npc_food]
]
Additional context
I was unable to generate a save file that would reproduce this. loading the save and saving it again does not trigger the issue.
The text was updated successfully, but these errors were encountered: