-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Segfault when sleeping with an alarm set #30522
Comments
I was able to repro the crash.
Calling Lines 5362 to 5367 in b68b6ca
And then Lines 5125 to 5131 in b68b6ca
On the
Crash here (bogus pointer for Lines 1141 to 1144 in b68b6ca
Iterator is possibly invalidated during the
The |
process_effects() does a for loop over *effects, calling process_one_effect() for each effect. process_one_effect() calls hardcoded_effects(). When the effect is effect_sleep, hardcoded_effects() can call removes_effect() on effect_alarm_clock, e.g. you wake up before your alarm goes off. Then, process_effects() continues iterating over *effects, even though effect_alarm_clock has been removed. That's why it only happens when you set the alarm. |
Yep you're absolutely right. I should have focused on the alarm_clock effect which is easy to follow once you know ... what you are searching for 😃. In
Which calls
No idea on how to fix this though... We would need a way to transmit the information about the iterator invalidation but also give the loop the correct iterator... |
Is it possible to do it the way other effects are (scheduled to be) removed? By setting the duration to 0? |
Describe the bug
Going to sleep and setting an alarm (via internal chronometer) can cause the game to segfault when waking up.
Steps To Reproduce
Expected behavior
For the game to not crash
Versions and configuration
CLANG=1 TILES=1 RUNTESTS=0 LINTJSON=0 BACKTRACE=0 DEBUG_SYMBOLS=1
)Dark Days Ahead [dda],
Disable NPC Needs [no_npc_food],
Aftershock [aftershock],
Bens GF recipes [Tolerate_This],
Craftable Gun Pack [craftgp],
DeadLeaves' Fictional Guns [FIC_Weapons],
Garden Pots [growable-pots],
Icecoon's Arsenal [ew_pack],
Makeshift Items Mod [makeshift],
Medieval and Historic Content [Medieval_Stuff],
More Survival Tools [More_Survival_Tools],
Mythological Replicas [nw_pack],
DinoMod [DinoMod],
Modular Turrets [modular_turrets],
Salvaged Robots [Salvaged_Robots],
Hydroponics [hydroponics],
Mutant NPCs [mutant_npcs],
Beta National Guard Camp [national_guard_camp],
More Locations [more_locations],
Urban Development [Urban_Development],
Mapgen Demo [mapgen_demo],
Fuji's More Buildings [FujiStruct],
Boats [boats],
Folding Parts pack [deoxymod],
Vehicle Additions Pack [blazemod],
Tanks and Other Vehicles [Tanks],
Necromancy [necromancy],
No Fungal Monsters [No_Fungi],
Classes and Scenarios Mod [more_classes_scenarios],
Classic Roguelike Classes [RL_Classes],
Manual Bionic Installation [manualbionicinstall],
No Filthy Clothing [no_filthy_clothing],
Prevent Zombie Revivication [no_reviving_zombies],
Safe Autodoc [safeautodoc],
Simplified Nutrition [novitamins],
Sleep Deprivation [sleepdeprivation],
StatsThroughSkills [StatsThroughSkills]
]
Additional context
I've experienced this issue before independently, and also found it reproducible on the save provided in #30216. That issue was marked as solved, and the original reporter did not comment further, but it is still reproducible for me with the same save.
I've been able to reproduce it over several versions, compiling with both gcc and clang.
Save
Backtrace
From gdb
The text was updated successfully, but these errors were encountered: