bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
35.38k stars 3.49k forks source link

Segfault on default app on NixOS/NVIDIA GPU. #13753

Open Azercoco opened 3 months ago

Azercoco commented 3 months ago

Bevy version

bevy = "0.13.2"

[Optional] Relevant system information

What you did

I did try to launch the default app :

use bevy::{app::App, DefaultPlugins};

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .run();
}

using the nix shell

{ pkgs ? import <nixpkgs> { } }:

with pkgs;

mkShell rec {
  nativeBuildInputs = [
    pkg-config
    cargo
    rustc
    rustfmt
  ];
  buildInputs = [
    udev
    alsa-lib
    vulkan-loader
    xorg.libX11
    xorg.libXcursor
    xorg.libXi
    xorg.libXrandr # To use the x11 feature
    libxkbcommon
    wayland # To use the wayland feature
  ];
  LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;
  RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
}
nix-shell
cargo run

What went wrong

The application compiles without issue but when I launches it, the window open for a couple of second before encountering a segfault. I am not sure if the issue is Nix-OS related or NVIDIA related. The lack of useful log or similar issues make it very hard to troubleshoot.

Additional information

Logs :

2024-06-08T18:35:51.367195Z  WARN log: error setting XSETTINGS; Xft options won't reload automatically    
2024-06-08T18:35:51.376218Z  INFO bevy_winit::system: Creating new window "App" (0v1)
2024-06-08T18:35:51.376396Z  INFO log: Guessed window scale factor: 1.5    
DRM kernel driver 'nvidia-drm' in use. NVK requires nouveau.
2024-06-08T18:35:51.543181Z  INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce RTX 4070", vendor: 4318, device: 10118, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "555.42.02", backend: Vulkan }
2024-06-08T18:32024-06-08T18:35:51.367195Z  WARN log: error setting XSETTINGS; Xft options won't reload automatically    
2024-06-08T18:35:51.376218Z  INFO bevy_winit::system: Creating new window "App" (0v1)
2024-06-08T18:35:51.376396Z  INFO log: Guessed window scale factor: 1.5    
DRM kernel driver 'nvidia-drm' in use. NVK requires nouveau.
2024-06-08T18:35:51.543181Z  INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce RTX 4070", vendor: 4318, device: 10118, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "555.42.02", backend: Vulkan }
2024-06-08T18:35:51.900316Z  INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Linux 24.11 NixOS", kernel: "6.6.32", cpu: "Intel(R) Core(TM) i7-14700KF", core_count: "20", memory: "46.9 GiB" }
Segmentation fault (core dumped)5:51.900316Z  INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Linux 24.11 NixOS", kernel: "6.6.32", cpu: "Intel(R) Core(TM) i7-14700KF", core_count: "20", memory: "46.9 GiB" }
Segmentation fault (core dumped)
alice-i-cecile commented 3 months ago

Are you able to run with MinimalPlugins? The next step is to try and dissect what plugins are causing this: my guess is either rendering or perhaps even the gathering of the system info itself.

Azercoco commented 3 months ago

No issue with MinimalPlugins. The issue really seems to come from the Window.

MonaMayrhofer commented 3 months ago

This happens to me as well, since I switched to Wayland.

The log is not very useful ``` -> RUST_BACKTRACE=full cargo run Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.19s Running `target/debug/app` 2024-06-13T17:25:31.242649Z WARN log: error setting XSETTINGS; Xft options won't reload automatically 2024-06-13T17:25:31.247122Z INFO bevy_winit::system: Creating new window "App" (0v1) 2024-06-13T17:25:31.247453Z INFO log: Guessed window scale factor: 1 libEGL warning: egl: failed to create dri2 screen 2024-06-13T17:25:31.375265Z INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce GTX 1070", vendor: 4318, device: 7041, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "555.52.04", backend: Vulkan } 2024-06-13T17:25:32.013630Z INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Linux 24.05 NixOS", kernel: "6.6.32", cpu: "Intel(R) Core(TM) i7-6850K CPU @ 3.60GHz", core_count: "6", memory: "94.2 GiB" } 2024-06-13T17:25:32.172836Z WARN bevy_render::view::window: Couldn't get swap chain texture. This often happens with the Nvidia 550 driver. It can be safely ignored. zsh: segmentation fault (core dumped) RUST_BACKTRACE=full cargo run ```

After trying it out multiple times I managed to get a panic with a backtrace once, and a few times it seemed to start fine... I will try to look into this some more...

I'm pretty sure this is either an issue with Wayland or with the 555 nvidia driver - I didn't really make any other changes to my system since it worked.

Edit: I quickly reverted back to X11 using the 555 driver - no problems there, so it really seems to be a Wayland issue

MonaMayrhofer commented 3 months ago

I just noticed, the app doesn't immediately crash. It starts up just fine and even does stuff and is interactive - sometimes it runs for up to 3 seconds - then segfaults

MonaMayrhofer commented 3 months ago
Running with gdb produces a backtrace: ``` Thread 13 "Compute Task Po" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7ffff65736c0 (LWP 36603)] 0x00007fffc68086b7 in ?? () from /nix/store/gngdpc8d4wijim959f65nwn9ssk84zv1-nvidia-x11-555.52.04-6.6.32/lib/libnvidia-glcore.so.555.52.04 (gdb) backtrace #0 0x00007fffc68086b7 in ?? () from /nix/store/gngdpc8d4wijim959f65nwn9ssk84zv1-nvidia-x11-555.52.04-6.6.32/lib/libnvidia-glcore.so.555.52.04 #1 0x00007fffc6be7079 in ?? () from /nix/store/gngdpc8d4wijim959f65nwn9ssk84zv1-nvidia-x11-555.52.04-6.6.32/lib/libnvidia-glcore.so.555.52.04 #2 0x00007fffc6bfe780 in ?? () from /nix/store/gngdpc8d4wijim959f65nwn9ssk84zv1-nvidia-x11-555.52.04-6.6.32/lib/libnvidia-glcore.so.555.52.04 #3 0x00007fffc6b3aede in ?? () from /nix/store/gngdpc8d4wijim959f65nwn9ssk84zv1-nvidia-x11-555.52.04-6.6.32/lib/libnvidia-glcore.so.555.52.04 #4 0x0000555559681b04 in ash::device::Device::wait_for_fences (self=0x55555bb43c90, fences=..., wait_all=true, timeout=18446744073709551615) at /home/nionidh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ash-0.37.3+1.3.251/src/device.rs:2399 #5 0x000055555958c57e in wgpu_hal::vulkan::instance::{impl#6}::acquire_texture (self=0x7fffd0003860, timeout=...) at src/vulkan/instance.rs:967 #6 0x0000555559189a4e in wgpu_core::global::Global::surface_get_current_texture (self=0x55555b71c320, surface_id=..., texture_id_in=()) at /home/nionidh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-core-0.19.3/src/present.rs:167 #7 0x00005555592f93b4 in wgpu::backend::wgpu_core::{impl#7}::surface_get_current_texture (self=0x55555b71c320, surface=0x7ffff656eac0, surface_data=0x7fffd0003680) at src/backend/wgpu_core.rs:744 #8 0x0000555559313f12 in wgpu::context::{impl#5}::surface_get_current_texture (self=0x55555b71c320, surface=0x7fffd011cce8, surface_data=...) at src/context.rs:2140 #9 0x000055555932518d in wgpu::Surface::get_current_texture (self=0x7fffd011ccb8) at src/lib.rs:4841 #10 0x0000555558dc3eaf in bevy_render::view::window::prepare_windows (windows=..., window_surfaces=..., render_device=..., render_adapter=..., screenshot_pipeline=..., pipeline_cache=..., pipelines=..., msaa=..., render_instance=...) at src/view/window/mod.rs:336 #11 0x0000555558a1b24d in core::ops::function::FnMut::call_mut, bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::ResMut>, bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::Res), (bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::ResMut>, bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::Res)> () at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/core/src/ops/function.rs:166 #12 0x0000555558d594f5 in core::ops::function::impls::{impl#3}::call_mut<(bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::ResMut>, bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::Res), fn(bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::ResMut>, bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::Res)> (self=0x7ffff6570548, args=...) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/core/src/ops/function.rs:294 #13 0x00005555588f5efd in bevy_ecs::system::function_system::{impl#27}::run::call_inner<(), bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::ResMut>, bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::Res, &mut fn(bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::ResMut>, bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::Res)> (f=0x55555bbb652c, F0=..., F1=..., F2=..., F3=..., F4=..., F5=..., F6=..., F7=..., F8=...) at /home/nionidh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.13.2/src/system/function_system.rs:656 #14 0x0000555558d568e5 in bevy_ecs::system::function_system::{impl#27}::run<(), fn(bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::ResMut>, bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::Res), bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::ResMut>, bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::Res> (self=0x55555bbb652c, param_value=...) at /home/nionidh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.13.2/src/system/function_system.rs:659 #15 0x00005555588d6602 in bevy_ecs::system::function_system::{impl#6}::run_unsafe, bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::ResMut>, bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::Res), fn(bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::Res, bevy_ecs::change_detection::ResMut>, bevy_ecs::change_detection::ResMut, bevy_ecs::change_detection::Res)> (self=0x55555bbb63c0, input=(), world=...) at /home/nionidh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.13.2/src/system/function_system.rs:499 #16 0x000055555a570289 in bevy_ecs::schedule::executor::multi_threaded::{impl#3}::spawn_system_task::{async_block#0}::{closure#0} () at src/schedule/executor/multi_threaded.rs:534 #17 0x000055555a59d349 in core::ops::function::FnOnce::call_once () at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/core/src/ops/function.rs:250 #18 0x000055555a55fb99 in core::panic::unwind_safe::{impl#23}::call_once<(), bevy_ecs::schedule::executor::multi_threaded::{impl#3}::spawn_system_task::{async_block#0}::{closure_env#0}> (self=...) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/core/src/panic/unwind_safe.rs:272 #19 0x000055555a52478d in std::panicking::try::do_call, ()> (data=0x7ffff6570a70) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/std/src/panicking.rs:559 --Type for more, q to quit, c to continue without paging-- #20 0x000055555a53097b in __rust_try () #21 0x000055555a52339e in std::panicking::try<(), core::panic::unwind_safe::AssertUnwindSafe> (f=...) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/std/src/panicking.rs:523 #22 0x000055555a54f3fa in std::panic::catch_unwind, ()> ( f=) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/std/src/panic.rs:149 #23 0x000055555a56fba1 in bevy_ecs::schedule::executor::multi_threaded::{impl#3}::spawn_system_task::{async_block#0} () at src/schedule/executor/multi_threaded.rs:529 #24 0x000055555a55f747 in core::panic::unwind_safe::{impl#26}::poll (self=..., cx=0x7ffff6571318) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/core/src/panic/unwind_safe.rs:297 #25 0x000055555a5a8c3e in futures_lite::future::{impl#9}::poll::{closure#0}> () at /home/nionidh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-lite-2.3.0/src/future.rs:588 #26 0x000055555a55fc04 in core::panic::unwind_safe::{impl#23}::call_once, futures_lite::future::{impl#9}::poll::{closure_env#0}>> (self=...) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/core/src/panic/unwind_safe.rs:272 #27 0x000055555a524466 in std::panicking::try::do_call>>, core::task::poll::Poll<()>> (data=0x7ffff6570e18) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/std/src/panicking.rs:559 #28 0x000055555a53097b in __rust_try () #29 0x000055555a5234e8 in std::panicking::try, core::panic::unwind_safe::AssertUnwindSafe>>> (f=...) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/std/src/panicking.rs:523 #30 0x000055555a54f1bb in std::panic::catch_unwind>>, core::task::poll::Poll<()>> (f=...) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/std/src/panic.rs:149 #31 0x000055555a5a8ad0 in futures_lite::future::{impl#9}::poll> (self=..., cx=0x7ffff6571318) at /home/nionidh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-lite-2.3.0/src/future.rs:588 #32 0x000055555a4ed6de in async_executor::{impl#5}::spawn::{async_block#0}>, futures_lite::future::CatchUnwind>> () at /home/nionidh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-executor-1.9.1/src/lib.rs:158 #33 0x000055555a506197 in async_task::raw::{impl#3}::run::{closure#1}>, futures_lite::future::CatchUnwind>>, core::result::Result<(), alloc::boxed::Box<(dyn core::any::Any + core::marker::Send), alloc::alloc::Global>>, async_executor::{impl#5}::schedule::{closure_env#0}, ()> () at /home/nionidh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-task-4.7.0/src/raw.rs:550 #34 0x000055555a59bd14 in core::ops::function::FnOnce::call_once>, futures_lite::future::CatchUnwind>>, core::result::Result<(), alloc::boxed::Box<(dyn core::any::Any + core::marker::Send), alloc::alloc::Global>>, async_executor::{impl#5}::schedule::{closure_env#0}, ()>, ()> () at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/core/src/ops/function.rs:250 #35 0x000055555a55fc5c in core::panic::unwind_safe::{impl#23}::call_once>>, async_task::raw::{impl#3}::run::{closure_env#1}>, futures_lite::future::CatchUnwind>>, core::result::Result<(), alloc::boxed::Box<(dyn core::any::Any + core::marker::Send), alloc::alloc::Global>>, async_executor::{impl#5}::schedule::{closure_env#0}, ()>> (self=...) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/core/src/panic/unwind_safe.rs:272 #36 0x000055555a524bf8 in std::panicking::try::do_call>, futures_lite::future::CatchUnwind>>, core::result::Result<(), alloc::boxed::Box<(dyn core::any::Any + core::marker::Send), alloc::alloc::Global>>, async_executor::{impl#5}::schedule::{closure_env#0}, ()>>, core::task::poll::Poll>>> (data=0x7ffff6571180) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/std/src/panicking.rs:559 #37 0x000055555a53097b in __rust_try () #38 0x000055555a5240da in std::panicking::try>>, core::panic::unwind_safe::AssertUnwindSafe>, futures_lite::future::CatchUnwind>>, core::result::Result<(), alloc::boxed::Box<(dyn core::any::Any + core::marker::Send), alloc::alloc::Global>>, async_executor::{impl#5}::schedule::{closure_env#0}, ()>>> (f=...) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/std/src/panicking.rs:523 #39 0x000055555a54f34b in std::panic::catch_unwind>, futures_lite::future::CatchUnwind>>, core::result::Result<(), alloc::boxed::Box<(dyn core::any::Any + core::marker::Send), alloc::alloc::Global>>, async_executor::{impl#5}::schedule::{closure_env#0}, ()>>, core::task::poll::Poll>>> (f=...) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/std/src/panic.rs:149 #40 0x000055555a5032c4 in async_task::raw::RawTask>, futures_lite::future::CatchUnwind>>, core::result::Result<(), alloc::boxed::Box<(dyn core::any::Any + core::marker::Send), alloc::alloc::Global>>, async_executor::{impl#5}::schedule::{closure_env#0}, ()>::run>, futures_lite::future::CatchUnwind>>, core::result::Result<(), alloc::boxed::Box<(dyn core::any::Any + core::marker::Send), alloc::alloc::Global>>, async_executor::{impl#5}::schedule::{closure_env#0}, ()> (ptr=0x7fffcc05c570) at /home/nionidh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-task-4.7.0/src/raw.rs:549 #41 0x000055555a5df94f in async_task::runnable::Runnable<()>::run<()> (self=...) at /home/nionidh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-task-4.7.0/src/runnable.rs:781 #42 0x000055555a5be676 in async_executor::{impl#5}::run::{async_fn#0}::{async_block#0}, futures_lite::future::Or>> () at /home/nionidh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-executor-1.9.1/src/lib.rs:254 #43 0x000055555a5bbd05 in futures_lite::future::{impl#7}::poll, futures_lite::future::Or>, async_executor::{impl#5}::run::{async_fn#0}::{async_block_env#0}, futures_lite::future::Or>>> (self=..., cx=0x7ffff6571dc0) at /home/nionidh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-lite-2.3.0/src/future.rs:449 #44 0x000055555a5be239 in async_executor::{impl#5}::run::{async_fn#0}, futures_lite::future::Or>> () at /home/nionidh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-executor-1.9.1/src/lib.rs:261 #45 0x000055555a5b5273 in futures_lite::future::block_on::{closure#0}, async_executor::{impl#5}::run::{async_fn_env#0}, futures_lite::f--Type for more, q to quit, c to continue without paging--c uture::Or>>> (cache=0x7ffff65735c0) at /home/nionidh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-lite-2.3.0/src/future.rs:99 #46 0x000055555a5c44b7 in std::thread::local::LocalKey>::try_with, futures_lite::future::block_on::{closure_env#0}, async_executor::{impl#5}::run::{async_fn_env#0}, futures_lite::future::Or>>>, core::result::Result<(), async_channel::RecvError>> (self=0x55555a9fe6e8, f=...) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/std/src/thread/local.rs:286 #47 0x000055555a5c43c4 in std::thread::local::LocalKey>::with, futures_lite::future::block_on::{closure_env#0}, async_executor::{impl#5}::run::{async_fn_env#0}, futures_lite::future::Or>>>, core::result::Result<(), async_channel::RecvError>> (self=0x55555a9fe6e8, f=...) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/std/src/thread/local.rs:262 #48 0x000055555a5b505d in futures_lite::future::block_on, async_executor::{impl#5}::run::{async_fn_env#0}, futures_lite::future::Or>>> (future=...) at /home/nionidh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-lite-2.3.0/src/future.rs:78 #49 0x000055555a5c89c2 in bevy_tasks::task_pool::{impl#2}::new_internal::{closure#0}::{closure#0}::{closure#0}::{closure#0} () at src/task_pool.rs:180 #50 0x000055555a5c1a51 in std::panicking::try::do_call> (data=0x7ffff65725a8) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/std/src/panicking.rs:559 #51 0x000055555a5c34db in __rust_try () #52 0x000055555a5c1808 in std::panicking::try, bevy_tasks::task_pool::{impl#2}::new_internal::{closure#0}::{closure#0}::{closure#0}::{closure_env#0}> (f=...) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/std/src/panicking.rs:523 #53 0x000055555a5c178e in std::panic::catch_unwind> (f=...) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/std/src/panic.rs:149 #54 0x000055555a5c86cc in bevy_tasks::task_pool::{impl#2}::new_internal::{closure#0}::{closure#0}::{closure#0} (local_executor=0x7ffff6573530) at src/task_pool.rs:174 #55 0x000055555a5c46d1 in std::thread::local::LocalKey::try_with ( self=0x55555a9fee70, f=...) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/std/src/thread/local.rs:286 #56 0x000055555a5c42db in std::thread::local::LocalKey::with ( self=0x55555a9fee70, f=...) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/std/src/thread/local.rs:262 #57 0x000055555a5c84d5 in bevy_tasks::task_pool::{impl#2}::new_internal::{closure#0}::{closure#0} () at src/task_pool.rs:167 #58 0x000055555a5c4236 in std::sys_common::backtrace::__rust_begin_short_backtrace (f=) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/std/src/sys_common/backtrace.rs:155 #59 0x000055555a5cbedd in std::thread::{impl#0}::spawn_unchecked_::{closure#2}::{closure#0} () at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/std/src/thread/mod.rs:542 #60 0x000055555a5b4e71 in core::panic::unwind_safe::{impl#23}::call_once<(), std::thread::{impl#0}::spawn_unchecked_::{closure#2}::{closure_env#0}> ( self=...) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/core/src/panic/unwind_safe.rs:272 #61 0x000055555a5c1ab5 in std::panicking::try::do_call>, ()> (data=0x7ffff65728f0) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/std/src/panicking.rs:559 #62 0x000055555a5c34db in __rust_try () #63 0x000055555a5c1932 in std::panicking::try<(), core::panic::unwind_safe::AssertUnwindSafe>> (f=...) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/std/src/panicking.rs:523 #64 0x000055555a5cb9b9 in std::panic::catch_unwind>, ()> (f=) at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/std/src/panic.rs:149 #65 std::thread::{impl#0}::spawn_unchecked_::{closure#2} () at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/std/src/thread/mod.rs:541 #66 0x000055555a5b75bf in core::ops::function::FnOnce::call_once, ()> () at /rustc/7bb6510fc1899b008837a376a7fdf31b341cc1bb/library/core/src/ops/function.rs:250 #67 0x000055555a7c690b in alloc::boxed::{impl#48}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2022 #68 alloc::boxed::{impl#48}::call_once<(), alloc::boxed::Box, alloc::alloc::Global>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:2022 #69 std::sys::pal::unix::thread::{impl#2}::new::thread_start () at library/std/src/sys/pal/unix/thread.rs:108 #70 0x00007ffff7c3d272 in start_thread () from /nix/store/k7zgvzp2r31zkg9xqgjim7mbknryv6bs-glibc-2.39-52/lib/libc.so.6 #71 0x00007ffff7cb8dec in clone3 () from /nix/store/k7zgvzp2r31zkg9xqgjim7mbknryv6bs-glibc-2.39-52/lib/libc.so.6 ```

Especially this part is interesting:

#4  0x0000555559681b04 in ash::device::Device::wait_for_fences (self=0x55555bb43c90, fences=..., wait_all=true, timeout=18446744073709551615)
    at /home/nionidh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ash-0.37.3+1.3.251/src/device.rs:2399
#5  0x000055555958c57e in wgpu_hal::vulkan::instance::{impl#6}::acquire_texture (self=0x7fffd0003860, timeout=...) at src/vulkan/instance.rs:967
#6  0x0000555559189a4e in wgpu_core::global::Global<wgpu_core::identity::IdentityManagerFactory>::surface_get_current_texture<wgpu_core::identity::IdentityManagerFactory, wgpu_hal::vulkan::Api> (self=0x55555b71c320, surface_id=..., 
    texture_id_in=()) at /home/nionidh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-core-0.19.3/src/present.rs:167
#7  0x00005555592f93b4 in wgpu::backend::wgpu_core::{impl#7}::surface_get_current_texture (self=0x55555b71c320, surface=0x7ffff656eac0, surface_data=0x7fffd0003680) at src/backend/wgpu_core.rs:744
#8  0x0000555559313f12 in wgpu::context::{impl#5}::surface_get_current_texture<wgpu::backend::wgpu_core::ContextWgpuCore> (self=0x55555b71c320, surface=0x7fffd011cce8, surface_data=...) at src/context.rs:2140
#9  0x000055555932518d in wgpu::Surface::get_current_texture (self=0x7fffd011ccb8) at src/lib.rs:4841
#10 0x0000555558dc3eaf in bevy_render::view::window::prepare_windows (windows=..., window_surfaces=..., render_device=..., render_adapter=..., screenshot_pipeline=..., pipeline_cache=..., pipelines=..., msaa=..., render_instance=...)
    at src/view/window/mod.rs:336
MonaMayrhofer commented 3 months ago

Oh my god...

Well, for me at least adding the "wayland" feature to bevy fixed the crash.

I suspect without it bevy was run with xwayland and then weirdness ensued... I will investigate further tho until I am 100% sure.

Edit: Yup!

without having features = ["wayland"] the app silently runs under xwayland and crashes after a few seconds. When adding features = ["wayland"] the app runs natively on wayland and works just fine.

MonaMayrhofer commented 3 months ago

So i guess the real bug here is that bevy crashes on xwayland - otherwise everything works as expected. I wonder if we should detect whether or not we are running in wayland and then print a warning if the app was built without the wayland feature

MonaMayrhofer commented 3 months ago

So this issue is really just #8788 with added segfault spicyness

And when #10792 is merged this shouldn't be a big problem anymore...

Azercoco commented 3 months ago

without having features = ["wayland"] the app silently runs under xwayland and crashes after a few seconds. When adding features = ["wayland"] the app runs natively on wayland and works just fine.

This also fixed the problem for me. Thanks.