-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some nested queries now cause ECS to crash (introduced in commit 3efbaca10452427385822f79208ff3a78ab9edda) #398
Comments
Before that commit queries wouldn't get their archetype accesses set properly and so when borrowing from world they were sometimes borrowing stuff without marking it as borrowed. Which let you do do stuff like run two systems that borrow T mutably in parallel (which is UB). And likewise in that example code you're borrowing |
So if I understand correctly, previously there was a race condition and now that it is fixed this is actually expected to break, correct? |
It wasn't a race condition (the parallel system was a bad example), just us not setting what data a query borrows which meant that it couldn't mark components as borrowed which meant that the runtime borrow check enforcement couldn't work(...I think? I haven't had a chance to properly look into why it happens but I think this is probably why). But yeah, long story short is that this code is expected to panic. I've absolutely no idea if it's possible to make this kind of thing compile time enforceable though x) |
Legion doesn't have this problem because iterating a query requires borrowing of Since bevy hides I think the current panic behavior is the best what can be done without sacrificing API usability. |
ok I will close this ticket in that case. Thanks for the info! |
Introduced in commit 3efbaca
Error occurs when a system has nested queries that involve the same component.
thread 'Compute Task Pool (1)' panicked at 'client::ui::components::focus::Focus already borrowed', /Users/ashneverdawn/.cargo/git/checkouts/bevy-f7ffde730c324c74/8106f77/crates/bevy_ecs/hecs/src/archetype.rs:196:13
Example code that panics:
The text was updated successfully, but these errors were encountered: