-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Registered systems that unregister themselves panic #22380
Copy link
Copy link
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorP-RegressionFunctionality that used to work but no longer does. Add a test for this!Functionality that used to work but no longer does. Add a test for this!S-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplished
Milestone
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorP-RegressionFunctionality that used to work but no longer does. Add a test for this!Functionality that used to work but no longer does. Add a test for this!S-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplished
Bevy version and features
bevy_ecs@0.18.0-rc2What you did
Reproduction repo
While this may seem contrived at first glance, it's a pretty useful pattern in my code base for ephemeral, self-cleaning event handlers.
What went wrong
Discussion
As far as I can tell, the main contributing factor to this bug was introduced in #19451, where
update_locationcan now panic. I tried a trivial fix for the offending insert:But this can't actually determine whether the queued commands will despawn it. I believe the despawning commands are flushed here, so there's no opportunity to check before updating the location.
A proper fix isn't obvious to me. Without larger changes to
update_locationsuch as making it fallible, the only solution I can see is simply not panicking (assuming it's not preserving any safety invariants). Naturally, not panicking poses its own issues.