Skip to content
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

Sorting causes segfault #213

Open
iiYese opened this issue Dec 19, 2024 · 1 comment
Open

Sorting causes segfault #213

iiYese opened this issue Dec 19, 2024 · 1 comment

Comments

@iiYese
Copy link
Contributor

iiYese commented Dec 19, 2024

Version: db1b212
Minimal setup to reproduce:

use core::cmp::Ordering;
use flecs_ecs::prelude::*;

#[derive(Component)]
struct Foo(u8);

fn foo_cmp(_: Entity, a: &&Foo, _: Entity, b: &&Foo) -> i32 {
    match a.0.cmp(&b.0) {
        Ordering::Less => -1,
        Ordering::Greater => 1,
        Ordering::Equal => 0,
    }
}

fn main() {
    let mut world = World::new();

    world.entity().set(Foo(0));
    world.entity().set(Foo(1));
    
    system!("foo_sort", world, &Foo)
        .kind::<flecs::pipeline::OnStore>()
        .order_by::<&Foo>(foo_cmp)
        .each(|_| {});

    world.progress();
}
@Indra-db
Copy link
Owner

tldr of discord conversation, it's because &T is passed in the order_by function instead of just T, which changes the function signature to &&T which causes the segfault. Need to patch this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants