-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Fetch::init_fetch's use in QueryState::par_for_each_unchecked_manual is unsound. #10752
Copy link
Copy link
Open
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsP-UnsoundA bug that results in undefined compiler behaviorA bug that results in undefined compiler behavior
Description
Bevy version
Potentially every one since QueryState::par_for_each_unchecked_manual was introduced.
What went wrong
The safety invariant on Fetch::init_fetch requires that must be legal for the fetch to access all matched components for a query, which is not true for QueryState::par_for_each_unchecked_manual, since it's initializing multiple Fetches in parallel and forcing them to access mutually exclusive parts of the query results. Either:
- ...the safety invariant needs to be more clearly worded and dependent safety invariants updated.
- ...we should be using a more scoped way to fetch query results.
Given that Fetch implementations are the lowest in the access hierarchy, I'd suggest option 1 and being more stringent in how we pair Fetch initialization and retrieval.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsP-UnsoundA bug that results in undefined compiler behaviorA bug that results in undefined compiler behavior