Skip to content

Stack overflow with large-ish Bundle spawn #20571

@ejrh

Description

@ejrh

## Bevy version and features

Bevy main, since #20422 was merged in ad36585

Using "experimental_bevy_feathers" feature.

stacktrace.txt

[Optional] Relevant system information

Windows 11 64 bit. Standard Rustup setup.

stable-x86_64-pc-windows-msvc
cargo 1.88.0 (873a06493 2025-05-10)
(bug still happens with cargo 1.89.0 (c24e10642 2025-06-23))

What you did

Run the "feathers" example:

cargo r --example feathers --features="experimental_bevy_feathers"
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.35s
     Running `target\debug\examples\feathers.exe`
2025-08-14T06:39:35.039573Z  INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Windows 11 Home", kernel: "26100", cpu: "AMD Ryzen 9 9900X3D 12-Core Processor", core_count: "12", memory: "61.6 GiB" }
2025-08-14T06:39:35.260736Z  INFO bevy_render::renderer: AdapterInfo { name: "AMD Radeon RX 7600", vendor: 4098, device: 29824, device_type: DiscreteGpu, driver: "AMD proprietary driver", driver_info: "25.6.1 (LLPC)", backend: Vulkan }
2025-08-14T06:39:35.500139Z  INFO bevy_render::batching::gpu_preprocessing: GPU preprocessing is fully supported on this device.
2025-08-14T06:39:35.522873Z  INFO bevy_winit::system: Creating new window feathers (0v0)

thread 'main' has overflowed its stack
error: process didn't exit successfully: `target\debug\examples\feathers.exe` (exit code: 0xc00000fd, STATUS_STACK_OVERFLOW)

I used "git bisect" to narrow down where the bug first occurs to commit ad36585.

What went wrong

Expecting: a nice "Feathers" example with various widgets I can play with.
Got: a stack overflow

Additional information

I was able to get a stack trace from the RustRover debugger, so skip my theorising if you like... Stack trace attached, updated for latest commit d95313b and to remove my printlns so the line numbers are more accurate,

stacktrace.txt

I don't think the color slider code added in this commit causes the problem, except insofar as the "impl Bundle" returned by demo_root has grown larger.

The problem does not occur in release mode, nor if I remove some of the nodes added in demo_root. Removing either all the newly-added color sliders, or all the pre-existing widgets and leaving the color sliders intact seems to work.

My theory would be either endless function recursion, or an excessive frame size in a function call. I am not an expert on Windows or Rust compilation, so I have mostly made progress by adding "println!" macros at various places. The setup system completes but another system set to run straight afterwards never gets to run:

...
app.add_systems(Startup, print_stuff.after(setup));
...

fn print_stuff() {
    println!("stuff!");     // this isn't printed
}

Adding more printing, it seems that all the individual commands are applied in apply_or_drop_queued, but then it's not clear if control ever returns to the caller. Maybe some Drop code runs and that's where it all goes wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-UIGraphical user interfaces, styles, layouts, and widgetsC-BugAn unexpected or incorrect behaviorS-Needs-TestingTesting must be done before this is safe to merge

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions