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

Crash on Widnows 11 with exit code: 0xc0000005, STATUS_ACCESS_VIOLATION #14149

Open
eidloi opened this issue Jul 5, 2024 · 10 comments
Open

Crash on Widnows 11 with exit code: 0xc0000005, STATUS_ACCESS_VIOLATION #14149

eidloi opened this issue Jul 5, 2024 · 10 comments
Labels
C-Bug An unexpected or incorrect behavior O-Windows Specific to the Windows desktop operating system P-Crash A sudden unexpected crash

Comments

@eidloi
Copy link
Contributor

eidloi commented Jul 5, 2024

Bevy version

0.14

[Optional] Relevant system information

If you cannot get Bevy to build or run on your machine, please include:

  • cargo --version: cargo 1.79.0 (ffa9cf99a 2024-06-03)
  • Processor: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz 2.59 GHz
  • Windows:
Edition	Windows 11 Home
Version		23H2
Installed on	‎11/‎11/‎2022
OS build	22631.3737
Experience	Windows Feature Experience Pack 1000.22700.1009.0

If your bug is rendering-related, copy the adapter info that appears when you run Bevy.

`AdapterInfo { name: "NVIDIA GeForce RTX 2070", vendor: 4318, device: 7938, device_type: DiscreteGpu, backend: Vulkan }`

What you did

Tried running a basic Bevy app:

use bevy::prelude::*;

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

What went wrong

   Compiling crash_test v0.1.0 (C:\Rust\crash_test)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 3m 26s
     Running `target\debug\crash_test.exe`
2024-07-05T08:51:33.688120Z  INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Windows 11 Home", kernel: "22631", cpu: "Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz", core_count: "6", memory: "15.9 GiB" }
error: process didn't exit successfully: `target\debug\crash_test.exe` (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)

Additional information

I tried forcing the wgpu version that has a fix for a crash, but it didn't help:

[patch.crates-io]
wgpu = { git = 'https://github.com/gfx-rs/wgpu.git', tag = "v0.20.2" }
@eidloi eidloi added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jul 5, 2024
@mockersf
Copy link
Member

mockersf commented Jul 5, 2024

could you try with a debugger to find where it crashes?

@mockersf mockersf added P-Crash A sudden unexpected crash O-Windows Specific to the Windows desktop operating system and removed S-Needs-Triage This issue needs to be labelled labels Jul 5, 2024
@eidloi
Copy link
Contributor Author

eidloi commented Jul 5, 2024

could you try with a debugger to find where it crashes?

yes will try to debug

@eidloi
Copy link
Contributor Author

eidloi commented Jul 5, 2024

Debugger error message: Stop reason: Exception 0xc0000005 encountered at address 0x7ffb335a3c6b: Access violation reading location 0x00000000

The stack trace leads me to:
Screenshot 2024-07-05 213439

@eidloi
Copy link
Contributor Author

eidloi commented Jul 5, 2024

There is a ticket on the wgpu side for this issue it seems: gfx-rs/wgpu#5879

@mockersf
Copy link
Member

mockersf commented Jul 5, 2024

Your stack trace seems to be in the OpenGL backend, but the log in the issue says Vulkan. Which are you using?

The interesting part in your screenshot is probably the stack trace, and you cut it so we don't have the functions. Could you post it as text?

@eidloi
Copy link
Contributor Author

eidloi commented Jul 5, 2024

Your stack trace seems to be in the OpenGL backend, but the log in the issue says Vulkan. Which are you using?

The interesting part in your screenshot is probably the stack trace, and you cut it so we don't have the functions. Could you post it as text?

I am not specifying the backend, I honestly thought it would go to DX12. Here is the callstack, hope it's the right one:

DumpRegistryKeyDefinitions (@DumpRegistryKeyDefinitions:3052)
RegisterProcTableCallback (@RegisterProcTableCallback:5458)
DumpRegistryKeyDefinitions (@DumpRegistryKeyDefinitions:3052)
DrvSetContext (@DrvSetContext:167)
wglSwapLayerBuffers (@wglSwapLayerBuffers:577)
wglMakeCurrent (@wglMakeCurrent:65)
1432E47C3 (c:\Users\tamas\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-hal-0.21.1\src\gles\wgl.rs:125)
union enum2$<core::result::Result<wgpu_hal::gles::wgl::Instance,wgpu_hal::InstanceError> > wgpu_hal::gles::wgl::impl$13::init(struct wgpu_hal::InstanceDescriptor *) (c:\Users\tamas\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-hal-0.21.1\src\gles\wgl.rs:449)
143080FD5 (c:\Users\tamas\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-core-0.21.1\src\instance.rs:82)
struct wgpu_core::instance::Instance wgpu_core::instance::Instance::new(struct ref$<str$>, struct wgpu_types::InstanceDescriptor) (c:\Users\tamas\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-core-0.21.1\src\instance.rs:111)
struct wgpu_core::global::Global wgpu_core::global::Global::new(struct ref$<str$>, struct wgpu_types::InstanceDescriptor) (c:\Users\tamas\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-core-0.21.1\src\global.rs:56)
struct wgpu::backend::wgpu_core::ContextWgpuCore wgpu::backend::wgpu_core::impl$7::init(struct wgpu_types::InstanceDescriptor) (c:\Users\tamas\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-0.20.1\src\backend\wgpu_core.rs:544)
struct wgpu::Instance wgpu::Instance::new(struct wgpu_types::InstanceDescriptor) (c:\Users\tamas\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-0.20.1\src\lib.rs:2029)
union enum2$<core::task::poll::Poll<tuple$<> > > bevy_render::impl$3::build::async_block$0(struct core::pin::Pin<ref_mut$<enum2$<bevy_render::impl$3::build::async_block_env$0> > >, struct core::task::wake::Context *) (c:\Users\tamas\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_render-0.14.0\src\lib.rs:276)
void futures_lite::future::block_on::closure$0<tuple$<>,enum2$<bevy_render::impl$3::build::async_block_env$0> >(struct futures_lite::future::block_on::closure_env$0<tuple$<>,enum2$<bevy_render::impl$3::build::async_block_env$0> >, struct core::cell::RefCell<tuple$<parking::Parker,core::task::wake::Waker> > *) (c:\Users\tamas\.cargo\registry\src\index.crates.io-6f17d22bba15001f\futures-lite-2.3.0\src\future.rs:99)
union enum2$<core::result::Result<tuple$<>,std::thread::local::AccessError> > std::thread::local::LocalKey<core::cell::RefCell<tuple$<parking::Parker,core::task::wake::Waker> > >::try_with<core::cell::RefCell<tuple$<parking::Parker,core::task::wake::Waker> >,futures_lite::future::block_on::closure_env$0<tuple$<>,enum2$<bevy_render::impl$3::build::async_block_env$0> >,tuple$<> >(struct futures_lite::future::block_on::closure_env$0<tuple$<>,enum2$<bevy_render::impl$3::build::async_block_env$0> >) (@std::thread::local::LocalKey<T>::try_with:40)
void std::thread::local::LocalKey<core::cell::RefCell<tuple$<parking::Parker,core::task::wake::Waker> > >::with<core::cell::RefCell<tuple$<parking::Parker,core::task::wake::Waker> >,futures_lite::future::block_on::closure_env$0<tuple$<>,enum2$<bevy_render::impl$3::build::async_block_env$0> >,tuple$<> >(struct futures_lite::future::block_on::closure_env$0<tuple$<>,enum2$<bevy_render::impl$3::build::async_block_env$0> >) (@std::thread::local::LocalKey<T>::with:7)
void futures_lite::future::block_on<tuple$<>,enum2$<bevy_render::impl$3::build::async_block_env$0> >(union enum2$<bevy_render::impl$3::build::async_block_env$0>) (c:\Users\tamas\.cargo\registry\src\index.crates.io-6f17d22bba15001f\futures-lite-2.3.0\src\future.rs:78)
void bevy_render::impl$3::build(struct bevy_render::RenderPlugin *, struct bevy_app::app::App *) (c:\Users\tamas\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_render-0.14.0\src\lib.rs:332)
void bevy_app::app::impl$2::add_boxed_plugin::closure$0(struct bevy_app::app::impl$2::add_boxed_plugin::closure_env$0 *) (c:\Users\tamas\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_app-0.14.0\src\app.rs:456)
void core::ops::function::FnOnce::call_once<bevy_app::app::impl$2::add_boxed_plugin::closure_env$0,tuple$<> >(struct bevy_app::app::impl$2::add_boxed_plugin::closure_env$0) (@core::ops::function::FnOnce::call_once:8)
void core::panic::unwind_safe::impl$25::call_once<tuple$<>,bevy_app::app::impl$2::add_boxed_plugin::closure_env$0>(struct core::panic::unwind_safe::AssertUnwindSafe<bevy_app::app::impl$2::add_boxed_plugin::closure_env$0>) (@<core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once:12)
void std::panicking::try::do_call<core::panic::unwind_safe::AssertUnwindSafe<bevy_app::app::impl$2::add_boxed_plugin::closure_env$0>,tuple$<> >(unsigned char *) (@std::panicking::try::do_call:16)
143C631E3 (@7ff73c1531e3..7ff73c153251:3)
union enum2$<core::result::Result<tuple$<>,alloc::boxed::Box<dyn$<core::any::Any,core::marker::Send>,alloc::alloc::Global> > > std::panicking::try<tuple$<>,core::panic::unwind_safe::AssertUnwindSafe<bevy_app::app::impl$2::add_boxed_plugin::closure_env$0> >(struct core::panic::unwind_safe::AssertUnwindSafe<bevy_app::app::impl$2::add_boxed_plugin::closure_env$0>) (@std::panicking::try:22)
union enum2$<core::result::Result<tuple$<>,alloc::boxed::Box<dyn$<core::any::Any,core::marker::Send>,alloc::alloc::Global> > > std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<bevy_app::app::impl$2::add_boxed_plugin::closure_env$0>,tuple$<> >(struct core::panic::unwind_safe::AssertUnwindSafe<bevy_app::app::impl$2::add_boxed_plugin::closure_env$0>) (@std::panic::catch_unwind:5)
union enum2$<core::result::Result<ref_mut$<bevy_app::app::App>,enum2$<bevy_app::app::AppError> > > bevy_app::app::App::add_boxed_plugin(struct alloc::boxed::Box<dyn$<bevy_app::plugin::Plugin>,alloc::alloc::Global>) (c:\Users\tamas\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_app-0.14.0\src\app.rs:456)
void bevy_app::plugin_group::PluginGroupBuilder::finish(struct bevy_app::plugin_group::PluginGroupBuilder, struct bevy_app::app::App *, struct core::panic::location::Location *) (c:\Users\tamas\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_app-0.14.0\src\plugin_group.rs:214)
<P as bevy_app::plugin::sealed::Plugins<bevy_app::plugin::sealed::PluginGroupMarker>>::add_to_app (c:\Users\tamas\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_app-0.14.0\src\plugin.rs:170)
bevy_app::app::App::add_plugins (c:\Users\tamas\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_app-0.14.0\src\app.rs:552)
static void crash_test::main() (c:\Rust\crash_test\src\main.rs:4)
void core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >( *) (@core::ops::function::FnOnce::call_once:6)
void std::sys_common::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<> >( *) (@std::sys_common::backtrace::__rust_begin_short_backtrace:6)
int std::rt::lang_start::closure$0<tuple$<> >(struct std::rt::lang_start::closure_env$0<tuple$<> > *) (@std::rt::lang_start::{{closure}}:7)
void std::rt::lang_start_internal() (@std::rt::lang_start_internal:28)
__int64 std::rt::lang_start<tuple$<> >( *, __int64, unsigned char * *, unsigned char) (@std::rt::lang_start:16)
main (@main:9)
static int __scrt_common_main_seh() (@7ff73c448f6c..7ff73c448fd3:3)
BaseThreadInitThunk (@BaseThreadInitThunk:12)
RtlUserThreadStart (@RtlUserThreadStart:12)

@eidloi
Copy link
Contributor Author

eidloi commented Jul 5, 2024

Your stack trace seems to be in the OpenGL backend, but the log in the issue says Vulkan. Which are you using?

The interesting part in your screenshot is probably the stack trace, and you cut it so we don't have the functions. Could you post it as text?

The sys info in the report is what github inserts in the template, I didn't paste it myself. It indeed goes along the OpenGL path but dies in an external (unsafe) call. Even though there is some error handing around it, it never returns the last OS error, but crashes instead

@eidloi
Copy link
Contributor Author

eidloi commented Jul 5, 2024

The call goes to:

winapi::um::wingdi::<extern>
pub unsafe fn wglMakeCurrent(hdc: HDC, hglrc: HGLRC) -> BOOL

@charletes
Copy link

charletes commented Aug 7, 2024

I had the same problem on windows for a couple weeks, but bevy 0.14.1 made it go away. Not sure exactly what the issue was, but after a "cargo update" it went away.
Also, I might have new nvidia drivers, but I'm not sure :(

@eidloi
Copy link
Contributor Author

eidloi commented Aug 7, 2024

I tried to update but no luck. However, I noticed that in Windows the integrated GPU is selected for my display and it turns out that switching to the dedicated GPU (make it the preferred one) solves the issue. Maybe windows switches over to the dedicated GPU after startup which causes the crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Bug An unexpected or incorrect behavior O-Windows Specific to the Windows desktop operating system P-Crash A sudden unexpected crash
Projects
None yet
Development

No branches or pull requests

3 participants