Skip to content

Stack overflow with ambiguity detection and .run_if(in_state(...)) #9641

Closed
@SorteKanin

Description

@SorteKanin

Bevy version

bevy = "0.11.2"

[Optional] Relevant system information

> cargo --version -v
cargo 1.71.1 (7f1d04c00 2023-07-29)
release: 1.71.1
commit-hash: 7f1d04c0053083b98fa50b69b6f56e339b0556a8
commit-date: 2023-07-29
host: x86_64-pc-windows-msvc
libgit2: 1.6.4 (sys:0.17.1 vendored)
libcurl: 8.0.1-DEV (sys:0.4.61+curl-8.0.1 vendored ssl:Schannel)
os: Windows 10.0.19045 (Windows 10 Home) [64-bit]

What you did

Minimal example:

use bevy::{
    ecs::schedule::{LogLevel, ScheduleBuildSettings},
    prelude::*,
};

#[derive(States, Clone, Copy, Default, Debug, PartialEq, Eq, Hash)]
enum DummyState {
    #[default]
    Foo,
    Bar,
}

fn main() {
    App::new()
        .edit_schedule(Update, |schedule| {
            schedule.set_build_settings(ScheduleBuildSettings {
                ambiguity_detection: LogLevel::Error,
                ..default()
            });
        })
        .add_state::<DummyState>()
        .add_plugins(DefaultPlugins)
        .add_systems(
            Update,
            (dummy_system, dummy_system).run_if(in_state(DummyState::Foo)),
        )
        .run()
}

fn dummy_system() {}

What went wrong

thread 'main' has overflowed its stack upon running.

Additional information

Note that using distributive_run_if seems to fix the problem. Also adding just one system (i.e. dummy_system.run_if(in_state(DummyState::Foo)) does not exhibit the problem. Problem happens even if different systems are used, the fact that it's the same system in the tuple is unrelated.

Only confirmed on Windows. Would be great if someone with a Linux/Mac machine, could confirm/deny if this happens on other platforms.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorS-Needs-InvestigationThis issue requires detective work to figure out what's going wrong

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions