[Bugfix] Fix segfault when animation callbacks start new animations #241
Labels
No labels
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
priority:tier4-deferred
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:procgen
system:python-binding
system:rendering
system:ui-hierarchy
Tiny Feature
workflow:blocked
workflow:needs-benchmark
workflow:needs-documentation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
john/McRogueFace#241
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Animation callbacks that started new animations on the same property caused a segfault in
AnimationManager::update(). This was a classic iterator invalidation bug.Root Cause
When an animation completes and its callback fires, if the callback starts a new animation with
REPLACEconflict mode (the default), the code would:existingAnim->complete()on the old animationactiveAnimations.erase()to remove the old animationBut this erase happened while
remove_ifwas still iterating overactiveAnimations, invalidating the iterator and causing a crash.Reproduction
Solution
Modified
AnimationManager::addAnimation()to handle theisUpdatingflag properly:During update loop (
isUpdating=true): Callstop()instead ofcomplete()on the existing animation, and let the update loop clean it up naturally. This avoids triggering the old animation's callback (which could cause infinite recursion) and avoids iterator invalidation.Outside update loop (
isUpdating=false): Preserve original behavior - callcomplete()and erase directly.Also fixed the pending animations processing to recognize when an animation is already the property lock holder (which happens when
addAnimationis called during a callback).Testing
tests/regression/recursive_animation_callback_segfault.pytest_animation_property_locking.pystill passes (8/8 tests)animate_method_test.pystill passestest_animation_callback_simple.pystill passesFiles Changed
src/Animation.cpp- ModifiedaddAnimation()and pending animations processing486087b9cbFixed by commit
d2ea64b("fix: animations modifying animations during callback is now safe"). Regression test added attests/regression/recursive_animation_callback_segfault.py.