Comments (2)
The clock has to be rewound back to 0.9
for it to crash as it should. But you don't get an access panic you get an error from the stdlib which is only in debug builds.
use bevy::prelude::*;
#[derive(Deref, DerefMut, Component)]
struct Foo(u32);
fn setup(mut cmds: Commands) {
cmds.spawn(Foo(0));
}
fn update(mut query: Query<AnyOf<(&mut Foo, &mut Foo)>>) {
let Ok((Some(mut a), Some(mut b))) = query.get_single_mut() else {
return;
};
**a += 1;
**b += 1;
println!("did a ub {} {}", **a, **b);
}
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_startup_system(setup)
.add_system(update)
.run();
}
did a ub 2 2
thread 'main' panicked at library/core/src/panicking.rs:220:5:
unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`
from bevy.
I was able to get it working(?) after some tinkering around with AnyOf
's update_component_access
impl.
diff --git a/crates/bevy_ecs/src/query/fetch.rs b/crates/bevy_ecs/src/query/fetch.rs
index 2ebf95cde..847653ab1 100644
--- a/crates/bevy_ecs/src/query/fetch.rs
+++ b/crates/bevy_ecs/src/query/fetch.rs
@@ -1872,10 +1872,12 @@ macro_rules! impl_anytuple_fetch {
$name::update_component_access($name, &mut intermediate);
_new_access.append_or(&intermediate);
_new_access.extend_access(&intermediate);
+ _access.extend_access(&intermediate); // add accesses for remaining items to check against
} else {
$name::update_component_access($name, &mut _new_access);
_new_access.required = _access.required.clone();
_not_first = true;
+ _access.extend_access(&_new_access); // add accesses for remaining items to check against
}
)*
diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs
index b41255194..075e04692 100644
--- a/crates/bevy_ecs/src/system/mod.rs
+++ b/crates/bevy_ecs/src/system/mod.rs
@@ -564,6 +564,14 @@ mod tests {
run_system(&mut world, sys);
}
+ #[test]
+ #[should_panic = "&mut bevy_ecs::system::tests::A conflicts with a previous access in this query."]
+ fn any_of_with_conflicting() {
+ fn sys(_: Query<AnyOf<(&mut A, &mut A)>>) {}
+ let mut world = World::default();
+ run_system(&mut world, sys);
+ }
+
#[test]
fn any_of_has_filter_with_when_both_have_it() {
fn sys(_: Query<(AnyOf<(&A, &A)>, &mut B)>, _: Query<&mut B, Without<A>>) {}
I have a very limited understanding of how this all works, so take this with a hefty grain of salt.
from bevy.
Related Issues (20)
- links in bevy/crates/bevy_ecs/README.md does not exist. HOT 1
- Track callsites of where observers are initially triggered. HOT 1
- `CombinatorSystem` is unsound HOT 2
- UI elements randomly disappear for some frames on specific android devices HOT 6
- Bevy needs better support for pre-multiplied alpha textures and sprites HOT 2
- Allow gizmos to render behind sprites
- UI rounding is applied before UI scaling HOT 5
- Footgun when chaining observer registrations on World vs App
- `embedded_asset!` does not work in multi-crate workspace + release build HOT 1
- viewport-to-world doesn't work well HOT 1
- Check benchmarks in CI HOT 1
- Consider what to do with wgpu_trace feature HOT 6
- Docs for Observer should mention what happens if you use a bundle in the `Trigger` HOT 1
- Add type registration for a11y::Focus
- AlphaToCoverage can't be used with base_color_texture
- `bevy` fails to build with just `bevy_dev_tools` feature HOT 2
- Adding proc_macro `#[required(TransformComponent, ...)]` for Component. HOT 3
- Update a TextureAtlas index based on the row and column of the TextureAtlasLayout::from_grid params
- `OnEnter(xx)` schedule will run before `Startup` HOT 1
- inconsistent animation transitions when current animation is completed HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bevy.