bevyengine / bevyengine/bevy

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

Open
#10,752 0 comments 1 reaction 0 assignees View on GitHub
A-ECS I-Unsound
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

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:

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.