Skip to content

Memory corruption bug in rustc causes UI panics on nightly #24952

Description

@s0lst1ce

Bevy version and features

Using Bevy 0.19 and rust nightly rustc 1.99.0-nightly (af3d95584 2026-07-09)
I'm using default features, dynamic_linking and debug.

What you did

I tried spawning a ui Node using bsn!. I tried to trim my code to something simple that still produces the error. Do note I still only tried it as part of my larger project. It is the only place with UI or bsn however.

impl Plugin for GameUiPlugin {
    fn build(&self, app: &mut App) {
        app
               .add_plugins(DefaultPlugins)
            .add_systems(OnEnter(AppState::InGame), summary.spawn());
    }
}

pub fn summary()    -> impl Scene {
    bsn! {
         Node {
            width: px(20), //same errors with `percent` instead
            height: px(80),
        }
    }
}

What went wrong

The program panics as soon as it's launched (I assume when the AppState::InGame state is entered). Specifically I get

thread 'Compute Task Pool (1)' (308695) panicked at /home/t/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/taffy-0.10.1/src/util/resolve.rs:68:18:
internal error: entered unreachable code
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `bevy_ui::layout::ui_layout_system`!
Encountered a panic in system `bevy_app::main_schedule::Main::run_main`!
free(): invalid size

The last line about the memory error changes to double free or corruption (out) and segmentation fault (core dumped) as well but I think that's unrelated to the problem and a side-effect of the panic from unreachable instead.

Additional information

Following a discussion with @tmstorey on discord they dug up the relevant taffy code

fn maybe_resolve(self, context: Option<f32>, calc: impl Fn(*const (), f32) -> f32) -> Option<f32> {
        match self.0.tag() {
            CompactLength::AUTO_TAG => None,
            CompactLength::LENGTH_TAG => Some(self.0.value()),
            CompactLength::PERCENT_TAG => context.map(|dim| dim * self.0.value()),
            #[cfg(feature = "calc")]
            _ if self.0.is_calc() => context.map(|dim| calc(self.0.calc_value(), dim)),
            _ => unreachable!(),
        }
}

I don't understand how that unreachable could be reached. Using percent should have gone to the PERCENT_TAG branch I think. I'll admit I don't know much though, only just touching UI and bsn for the first time.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-Cross-CuttingImpacts the entire engineC-BugAn unexpected or incorrect behaviorP-HighThis is particularly urgent, and deserves immediate attention

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions