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

Wireframe plugin causes segmentation violation #1717

Closed
bonsairobo opened this issue Mar 21, 2021 · 12 comments
Closed

Wireframe plugin causes segmentation violation #1717

bonsairobo opened this issue Mar 21, 2021 · 12 comments
Labels
A-Rendering Drawing game state to the screen P-Crash A sudden unexpected crash

Comments

@bonsairobo
Copy link
Contributor

bonsairobo commented Mar 21, 2021

Bevy version

rev = d9fb61d

Operating system & version

Arch Linux

$ cat /etc/lsb-release 
DISTRIB_ID=ManjaroLinux
DISTRIB_RELEASE=21.0
DISTRIB_CODENAME=Ornara
DISTRIB_DESCRIPTION="Manjaro Linux"

What you did

I have an example running on top of bevy here: https://github.com/bonsairobo/building-blocks/tree/main/examples/lod_terrain

If you go to lod_terrain.rs and uncomment the wireframe stuff, then run the example, it will occasionally crash with a segfault.

What you expected to happen

Not crashing. And it does occasionally run without error. This is a nondeterministic bug.

What actually happened

Crashed with error:

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /home/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/d9fb61d/crates/bevy_wgpu/src/renderer/wgpu_render_resource_context.rs:560:68
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Mar 21 06:45:18.377 ERROR gpu_descriptor::allocator: `DescriptorAllocator` is dropped while some descriptor sets were not deallocated
Segmentation fault (core dumped)

Additional information

STACK TRACE

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /home/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/d9fb61d/crates/bevy_wgpu/src/renderer/wgpu_render_resource_context.rs:560:68
stack backtrace:
   0: rust_begin_unwind
             at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/core/src/panicking.rs:50:5
   3: core::option::Option<T>::unwrap
             at /home/duncan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs:386:21
   4: <bevy_wgpu::renderer::wgpu_render_resource_context::WgpuRenderResourceContext as bevy_render::renderer::render_resource_context::RenderResourceContext>::create_bind_group::{{closure}}
             at /home/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/d9fb61d/crates/bevy_wgpu/src/renderer/wgpu_render_resource_context.rs:560:47
   5: core::iter::adapters::map::map_fold::{{closure}}
             at /home/duncan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/adapters/map.rs:80:28
   6: core::iter::traits::iterator::Iterator::fold
             at /home/duncan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:2023:21
   7: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
             at /home/duncan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/adapters/map.rs:120:9
   8: core::iter::traits::iterator::Iterator::for_each
             at /home/duncan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:678:9
   9: <alloc::vec::Vec<T,A> as alloc::vec::SpecExtend<T,I>>::spec_extend
             at /home/duncan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec.rs:2568:17
  10: <alloc::vec::Vec<T> as alloc::vec::SpecFromIterNested<T,I>>::from_iter
             at /home/duncan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec.rs:2336:9
  11: <alloc::vec::Vec<T> as alloc::vec::SpecFromIter<T,I>>::from_iter
             at /home/duncan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec.rs:2346:9
  12: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter
             at /home/duncan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec.rs:2181:9
  13: core::iter::traits::iterator::Iterator::collect
             at /home/duncan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:1670:9
  14: <bevy_wgpu::renderer::wgpu_render_resource_context::WgpuRenderResourceContext as bevy_render::renderer::render_resource_context::RenderResourceContext>::create_bind_group
             at /home/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/d9fb61d/crates/bevy_wgpu/src/renderer/wgpu_render_resource_context.rs:544:27
  15: bevy_render::renderer::render_resource::render_resource_bindings::RenderResourceBindings::update_bind_group
  16: bevy_render::draw::DrawContext::set_bind_groups_from_bindings_internal
             at /home/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/d9fb61d/crates/bevy_render/src/draw.rs:270:21
  17: bevy_render::draw::DrawContext::set_bind_groups_from_bindings
             at /home/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/d9fb61d/crates/bevy_render/src/draw.rs:242:9
  18: bevy_render::wireframe::draw_wireframes_system::{{closure}}
             at /home/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/d9fb61d/crates/bevy_render/src/wireframe/mod.rs:103:9
  19: core::iter::traits::iterator::Iterator::for_each::call::{{closure}}
             at /home/duncan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:675:29
  20: core::iter::traits::iterator::Iterator::fold
             at /home/duncan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:2023:21
  21: core::iter::traits::iterator::Iterator::for_each
             at /home/duncan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:678:9
  22: bevy_render::wireframe::draw_wireframes_system
             at /home/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/d9fb61d/crates/bevy_render/src/wireframe/mod.rs:118:9
  23: core::ops::function::Fn::call
             at /home/duncan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:70:5
  24: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &F>::call_mut
             at /home/duncan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:247:13
  25: <Func as bevy_ecs::system::into_system::IntoSystem<(A,B,C,D,E),bevy_ecs::system::into_system::FuncSystem<Out>>>::system::{{closure}}
             at /home/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/d9fb61d/crates/bevy_ecs/src/system/into_system.rs:259:38
  26: bevy_ecs::schedule::executor_parallel::ParallelExecutor::prepare_systems::{{closure}}
             at /home/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/d9fb61d/crates/bevy_ecs/src/schedule/executor_parallel.rs:244:30
  27: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /home/duncan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/mod.rs:80:19
  28: async_executor::Executor::spawn::{{closure}}
             at /home/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.4.0/src/lib.rs:138:13
  29: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /home/duncan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/mod.rs:80:19
  30: async_task::raw::RawTask<F,T,S>::run
             at /home/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/async-task-4.0.3/src/raw.rs:489:20
  31: async_executor::Executor::try_tick
             at /home/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.4.0/src/lib.rs:175:17
  32: bevy_tasks::task_pool::TaskPool::scope::{{closure}}
             at /home/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/d9fb61d/crates/bevy_tasks/src/task_pool.rs:221:21
  33: std::thread::local::LocalKey<T>::try_with
             at /home/duncan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:272:16
  34: std::thread::local::LocalKey<T>::with
             at /home/duncan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:248:9
  35: bevy_tasks::task_pool::TaskPool::scope
             at /home/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/d9fb61d/crates/bevy_tasks/src/task_pool.rs:169:9
  36: <bevy_ecs::schedule::executor_parallel::ParallelExecutor as bevy_ecs::schedule::executor::ParallelSystemExecutor>::run_systems
             at /home/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/d9fb61d/crates/bevy_ecs/src/schedule/executor_parallel.rs:169:9
  37: <bevy_ecs::schedule::stage::SystemStage as bevy_ecs::schedule::stage::Stage>::run
             at /home/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/d9fb61d/crates/bevy_ecs/src/schedule/stage.rs:592:13
  38: bevy_ecs::schedule::Schedule::run_once
             at /home/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/d9fb61d/crates/bevy_ecs/src/schedule/mod.rs:198:13
  39: <bevy_ecs::schedule::Schedule as bevy_ecs::schedule::stage::Stage>::run
             at /home/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/d9fb61d/crates/bevy_ecs/src/schedule/mod.rs:209:21
  40: bevy_winit::winit_runner_with::{{closure}}
             at /home/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/d9fb61d/crates/bevy_winit/src/lib.rs:486:17
  41: winit::platform_impl::platform::sticky_exit_callback
             at /home/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.24.0/src/platform_impl/linux/mod.rs:736:5
  42: winit::platform_impl::platform::x11::EventLoop<T>::run_return
             at /home/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.24.0/src/platform_impl/linux/x11/mod.rs:303:17
  43: winit::platform_impl::platform::x11::EventLoop<T>::run
             at /home/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.24.0/src/platform_impl/linux/x11/mod.rs:398:9
  44: winit::platform_impl::platform::EventLoop<T>::run
             at /home/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.24.0/src/platform_impl/linux/mod.rs:652:56
  45: winit::event_loop::EventLoop<T>::run
             at /home/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.24.0/src/event_loop.rs:154:9
  46: bevy_winit::run
             at /home/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/d9fb61d/crates/bevy_winit/src/lib.rs:170:5
  47: bevy_winit::winit_runner_with
             at /home/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/d9fb61d/crates/bevy_winit/src/lib.rs:494:9
  48: bevy_winit::winit_runner
             at /home/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/d9fb61d/crates/bevy_winit/src/lib.rs:210:5
  49: core::ops::function::Fn::call
             at /home/duncan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:70:5
  50: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /home/duncan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1342:9
  51: bevy_app::app::App::run
             at /home/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/d9fb61d/crates/bevy_app/src/app.rs:66:9
  52: bevy_app::app_builder::AppBuilder::run
             at /home/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/d9fb61d/crates/bevy_app/src/app_builder.rs:50:9
  53: lod_terrain::main
             at ./examples/lod_terrain/lod_terrain.rs:27:5
  54: core::ops::function::FnOnce::call_once
             at /home/duncan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5

@alice-i-cecile alice-i-cecile added P-Crash A sudden unexpected crash A-Rendering Drawing game state to the screen labels Mar 21, 2021
@alice-i-cecile
Copy link
Member

Given the nondeterminism, I wonder if this is a system ordering issue.

@mockersf
Copy link
Member

mockersf commented Mar 21, 2021

I also have this issue on macOS.

Related to #1609 that should have been fixed by #1623

@bonsairobo
Copy link
Contributor Author

@mockersf Awesome! Sorry I did not see this. I will try updating to that fix revision and see how it goes.

@bonsairobo
Copy link
Contributor Author

bonsairobo commented Mar 21, 2021

OK I updated to 785aad9 and I'm getting what appears to be the same stack:

STACK TRACE

thread 'Compute Task Pool (1)' panicked at 'called `Option::unwrap()` on a `None` value', /Users/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/785aad9/crates/bevy_wgpu/src/renderer/wgpu_render_resource_context.rs:560:68
stack backtrace:
   0: rust_begin_unwind
             at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/core/src/panicking.rs:50:5
   3: core::option::Option<T>::unwrap
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/option.rs:386:21
   4: <bevy_wgpu::renderer::wgpu_render_resource_context::WgpuRenderResourceContext as bevy_render::renderer::render_resource_context::RenderResourceContext>::create_bind_group::{{closure}}
             at /Users/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/785aad9/crates/bevy_wgpu/src/renderer/wgpu_render_resource_context.rs:560:47
   5: core::iter::adapters::map::map_fold::{{closure}}
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/adapters/map.rs:80:28
   6: core::iter::traits::iterator::Iterator::fold
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:2023:21
   7: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/adapters/map.rs:120:9
   8: core::iter::traits::iterator::Iterator::for_each
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:678:9
   9: <alloc::vec::Vec<T,A> as alloc::vec::SpecExtend<T,I>>::spec_extend
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/vec.rs:2568:17
  10: <alloc::vec::Vec<T> as alloc::vec::SpecFromIterNested<T,I>>::from_iter
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/vec.rs:2336:9
  11: <alloc::vec::Vec<T> as alloc::vec::SpecFromIter<T,I>>::from_iter
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/vec.rs:2346:9
  12: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/vec.rs:2181:9
  13: core::iter::traits::iterator::Iterator::collect
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:1670:9
  14: <bevy_wgpu::renderer::wgpu_render_resource_context::WgpuRenderResourceContext as bevy_render::renderer::render_resource_context::RenderResourceContext>::create_bind_group
             at /Users/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/785aad9/crates/bevy_wgpu/src/renderer/wgpu_render_resource_context.rs:544:27
  15: bevy_render::renderer::render_resource::render_resource_bindings::RenderResourceBindings::update_bind_group
  16: bevy_render::draw::DrawContext::set_bind_groups_from_bindings_internal
             at /Users/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/785aad9/crates/bevy_render/src/draw.rs:273:21
  17: bevy_render::draw::DrawContext::set_bind_groups_from_bindings
             at /Users/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/785aad9/crates/bevy_render/src/draw.rs:245:9
  18: bevy_render::wireframe::draw_wireframes_system::{{closure}}
             at /Users/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/785aad9/crates/bevy_render/src/wireframe/mod.rs:110:9
  19: core::iter::traits::iterator::Iterator::for_each::call::{{closure}}
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:675:29
  20: core::iter::traits::iterator::Iterator::fold
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:2023:21
  21: core::iter::traits::iterator::Iterator::for_each
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:678:9
  22: bevy_render::wireframe::draw_wireframes_system
             at /Users/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/785aad9/crates/bevy_render/src/wireframe/mod.rs:125:9
  23: core::ops::function::Fn::call
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:70:5
  24: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &F>::call_mut
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:247:13
  25: <Func as bevy_ecs::system::into_system::SystemParamFunction<(),Out,(F0,F1,F2,F3,F4),()>>::run
             at /Users/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/785aad9/crates/bevy_ecs/src/system/into_system.rs:189:21
  26: <bevy_ecs::system::into_system::FunctionSystem<In,Out,Param,Marker,F> as bevy_ecs::system::system::System>::run_unsafe
             at /Users/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/785aad9/crates/bevy_ecs/src/system/into_system.rs:142:9
  27: bevy_ecs::schedule::executor_parallel::ParallelExecutor::prepare_systems::{{closure}}
             at /Users/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/785aad9/crates/bevy_ecs/src/schedule/executor_parallel.rs:200:30
  28: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/future/mod.rs:80:19
  29: async_executor::Executor::spawn::{{closure}}
             at /Users/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.4.0/src/lib.rs:138:13
  30: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/future/mod.rs:80:19
  31: async_task::raw::RawTask<F,T,S>::run
             at /Users/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/async-task-4.0.3/src/raw.rs:489:20
  32: async_executor::Executor::run::{{closure}}::{{closure}}
             at /Users/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.4.0/src/lib.rs:229:21
  33: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/future/mod.rs:80:19
  34: <futures_lite::future::Or<F1,F2> as core::future::future::Future>::poll
             at /Users/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-lite-1.11.3/src/future.rs:529:33
  35: async_executor::Executor::run::{{closure}}
             at /Users/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.4.0/src/lib.rs:236:9
  36: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/future/mod.rs:80:19
  37: futures_lite::future::block_on::{{closure}}
             at /Users/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-lite-1.11.3/src/future.rs:89:27
  38: std::thread::local::LocalKey<T>::try_with
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/thread/local.rs:272:16
  39: std::thread::local::LocalKey<T>::with
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/thread/local.rs:248:9
  40: futures_lite::future::block_on
             at /Users/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-lite-1.11.3/src/future.rs:79:5
  41: bevy_tasks::task_pool::TaskPool::new_internal::{{closure}}::{{closure}}
             at /Users/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/785aad9/crates/bevy_tasks/src/task_pool.rs:139:25
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread 'main' panicked at 'task has failed', /Users/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/async-task-4.0.3/src/task.rs:368:45
stack backtrace:
   0: rust_begin_unwind
             at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/core/src/panicking.rs:92:14
   2: core::option::expect_failed
             at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/core/src/option.rs:1260:5
   3: core::option::Option<T>::expect
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/option.rs:349:21
   4: <async_task::task::Task<T> as core::future::future::Future>::poll
             at /Users/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/async-task-4.0.3/src/task.rs:368:43
   5: bevy_tasks::task_pool::TaskPool::scope::{{closure}}::{{closure}}
             at /Users/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/785aad9/crates/bevy_tasks/src/task_pool.rs:194:38
   6: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/future/mod.rs:80:19
   7: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/future/future.rs:119:9
   8: async_executor::LocalExecutor::spawn::{{closure}}
             at /Users/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.4.0/src/lib.rs:366:13
   9: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/future/mod.rs:80:19
  10: async_task::raw::RawTask<F,T,S>::run
             at /Users/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/async-task-4.0.3/src/raw.rs:489:20
  11: async_executor::Executor::try_tick
             at /Users/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/async-executor-1.4.0/src/lib.rs:175:17
  12: bevy_tasks::task_pool::TaskPool::scope::{{closure}}
             at /Users/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/785aad9/crates/bevy_tasks/src/task_pool.rs:223:21
  13: std::thread::local::LocalKey<T>::try_with
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/thread/local.rs:272:16
  14: std::thread::local::LocalKey<T>::with
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/thread/local.rs:248:9
  15: bevy_tasks::task_pool::TaskPool::scope
             at /Users/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/785aad9/crates/bevy_tasks/src/task_pool.rs:169:9
  16: <bevy_ecs::schedule::executor_parallel::ParallelExecutor as bevy_ecs::schedule::executor::ParallelSystemExecutor>::run_systems
             at /Users/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/785aad9/crates/bevy_ecs/src/schedule/executor_parallel.rs:121:9
  17: <bevy_ecs::schedule::stage::SystemStage as bevy_ecs::schedule::stage::Stage>::run
             at /Users/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/785aad9/crates/bevy_ecs/src/schedule/stage.rs:602:13
  18: bevy_ecs::schedule::Schedule::run_once
             at /Users/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/785aad9/crates/bevy_ecs/src/schedule/mod.rs:201:13
  19: <bevy_ecs::schedule::Schedule as bevy_ecs::schedule::stage::Stage>::run
             at /Users/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/785aad9/crates/bevy_ecs/src/schedule/mod.rs:212:21
  20: bevy_winit::winit_runner_with::{{closure}}
             at /Users/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/785aad9/crates/bevy_winit/src/lib.rs:485:17
  21: <alloc::boxed::Box<F,A> as core::ops::function::FnMut<Args>>::call_mut
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1335:9
  22: <winit::platform_impl::platform::app_state::EventLoopHandler<T> as winit::platform_impl::platform::app_state::EventHandler>::handle_nonuser_event
             at /Users/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.24.0/src/platform_impl/macos/app_state.rs:71:9
  23: winit::platform_impl::platform::app_state::Handler::handle_nonuser_event
             at /Users/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.24.0/src/platform_impl/macos/app_state.rs:173:21
  24: winit::platform_impl::platform::app_state::AppState::cleared
             at /Users/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.24.0/src/platform_impl/macos/app_state.rs:331:13
  25: ____CFXPCCreateCFObjectFromXPCObject_block_invoke
  26: ___CFRunLoopObserverCancel
  27: ___CFRunLoopRun
  28: ___CFTSRToDispatchTime
  29: _RunCurrentEventLoopInMode
  30: _ReceiveNextEventCommon
  31: __BlockUntilNextEventMatchingListInModeWithFilter
  32: __DPSNextEvent
  33: -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]
  34: -[NSApplication run]
  35: <() as objc::message::MessageArguments>::invoke
             at /Users/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/objc-0.2.7/src/message/mod.rs:128:17
  36: objc::message::platform::send_unverified
             at /Users/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/objc-0.2.7/src/message/apple/mod.rs:27:9
  37: objc::message::send_message
             at /Users/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/objc-0.2.7/src/message/mod.rs:178:5
  38: winit::platform_impl::platform::event_loop::EventLoop<T>::run_return
             at /Users/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.24.0/src/platform_impl/macos/event_loop.rs:106:25
  39: winit::platform_impl::platform::event_loop::EventLoop<T>::run
             at /Users/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.24.0/src/platform_impl/macos/event_loop.rs:93:9
  40: winit::event_loop::EventLoop<T>::run
             at /Users/duncan/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.24.0/src/event_loop.rs:154:9
  41: bevy_winit::run
             at /Users/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/785aad9/crates/bevy_winit/src/lib.rs:171:5
  42: bevy_winit::winit_runner_with
             at /Users/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/785aad9/crates/bevy_winit/src/lib.rs:493:9
  43: bevy_winit::winit_runner
             at /Users/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/785aad9/crates/bevy_winit/src/lib.rs:211:5
  44: core::ops::function::Fn::call
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:70:5
  45: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1342:9
  46: bevy_app::app::App::run
             at /Users/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/785aad9/crates/bevy_app/src/app.rs:68:9
  47: bevy_app::app_builder::AppBuilder::run
             at /Users/duncan/.cargo/git/checkouts/bevy-f7ffde730c324c74/785aad9/crates/bevy_app/src/app_builder.rs:48:9
  48: lod_terrain::main
             at ./examples/lod_terrain/lod_terrain.rs:28:5
  49: core::ops::function::FnOnce::call_once
             at /Users/duncan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5

@Neo-Zhixing
Copy link
Contributor

@bonsairobo I wasn't able to compile the example - I will try again later, but can you put some println! in draw_wireframes_system and in draw_render_pipelines_system? We might be able to find some relationships between "if it's going to crash" and "does the draw_wireframe_system run before the main pipeline or after"

@bonsairobo
Copy link
Contributor Author

Oh yea I guess there is a broken dependency in bevy right now. I will do a little debugging later today hopefully when I can build bevy again.

@bonsairobo
Copy link
Contributor Author

Sorry I had a busy end of my week. But I just did a little debugging.

There does not appear to be a correlation between the system ordering and the crash.

When it crashes:

draw_wireframes_system
draw_render_pipelines_system
draw_wireframes_system
draw_render_pipelines_system
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value'

When it succeeds:

draw_wireframes_system
draw_render_pipelines_system
draw_wireframes_system
draw_render_pipelines_system
draw_wireframes_system
draw_render_pipelines_system
draw_wireframes_system
draw_render_pipelines_system
...

@mockersf
Copy link
Member

mockersf commented Apr 9, 2021

While trying to remove parts of my game to reach a minimum reproducer, here is what I found:

use bevy::{
    prelude::*,
    render::wireframe::{Wireframe, WireframePlugin},
    wgpu::{WgpuFeature, WgpuFeatures, WgpuOptions},
};

fn main() {
    App::build()
        .insert_resource(Msaa { samples: 4 })
        .insert_resource(WgpuOptions {
            features: WgpuFeatures {
                features: vec![WgpuFeature::NonFillPolygonMode],
            },
            ..Default::default()
        })
        .add_plugins(DefaultPlugins)
        .add_plugin(WireframePlugin)
        .add_startup_system(setup.system())
        .run();
}

fn setup(mut commands: Commands, mut meshes: ResMut<Assets<Mesh>>, asset_server: Res<AssetServer>) {
    commands.spawn_scene(asset_server.load("models/AlienCake/cakeBirthday.glb#Scene0"));

    commands
        .spawn_bundle(PbrBundle {
            mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
            transform: Transform::from_xyz(0.0, 0.5, 0.0),
            ..Default::default()
        })
        .insert(Wireframe);

    commands.spawn_bundle(PerspectiveCameraBundle {
        transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
        ..Default::default()
    });
}

This code crashes almost every time for me.

  • If I don't spawn the scene, it won't crash
  • If I don't add the Wireframe component, it won't crash
  • It doesn't seem to crash with a more complex model "models/FlightHelmet/FlightHelmet.gltf#Scene0"

@wdcocq
Copy link

wdcocq commented May 21, 2021

I ran into this issue as well and what i gathered so far is that after a resize of the buffer array it sometimes still tried to use the old buffer, which causes the panic.

The order of the draw systems (after the buffer resize) doesn't matter. I've seen it crash either way.

when I comment out this line in : render_resource_bindings#L146 I don't get the panic anymore.
So it seems that it sometimes gets removed from the dirty bindings before actually being rebuild. Probably because of the two pipelines reusing the same resource? I'm not too familiar with the whole rendering back-end stuff, so I don't know exactly what's going one. I just hope this helps..

@james7132
Copy link
Member

@bonsairobo: Is this still an issue? This was before the 0.6 render rework was done. If it isn't reproducible, please close this issue.

@mockersf
Copy link
Member

not reproducible for me 🎉

@bonsairobo
Copy link
Contributor Author

Although I haven't tried upgrading building-blocks per se, I also haven't noticed this issue anymore in my recent code that uses wireframes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen P-Crash A sudden unexpected crash
Projects
None yet
Development

No branches or pull requests

6 participants