Skip to content

Fetch::init_fetch's use in QueryState::par_for_each_unchecked_manual is unsound. #10752

@james7132

Description

@james7132

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:

  1. ...the safety invariant needs to be more clearly worded and dependent safety invariants updated.
  2. ...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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsP-UnsoundA bug that results in undefined compiler behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions