Skip to content

STATUS_ACCESS_VIOLATION in CorePipelinePlugin #13559

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

Closed
Weihnachtsbaum opened this issue May 28, 2024 · 19 comments
Closed

STATUS_ACCESS_VIOLATION in CorePipelinePlugin #13559

Weihnachtsbaum opened this issue May 28, 2024 · 19 comments
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior O-Windows Specific to the Windows desktop operating system S-Blocked This cannot move forward until something else changes
Milestone

Comments

@Weihnachtsbaum
Copy link

Bevy version

0.13.2

System information

  • cargo 1.80.0-nightly (84dc5dc11 2024-05-20)
  • Windows 10
`AdapterInfo { name: "Intel(R) HD Graphics 5500", vendor: 32902, device: 5654, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Dx12 }`

What you did

Initially I did this:

use bevy::prelude::*;
fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .run()
}

Then I tried narrowing the problem down and ended up with this:

fn main() {
    bevy_app::App::new()
        // MinimalPlugins
        .add_plugins(bevy_core::TaskPoolPlugin::default())
        .add_plugins(bevy_core::TypeRegistrationPlugin)
        .add_plugins(bevy_core::FrameCountPlugin)
        .add_plugins(bevy_time::TimePlugin)
        .add_plugins(bevy_app::ScheduleRunnerPlugin::default())

        // required for CorePipelinePlugin to run
        .add_plugins(bevy_window::WindowPlugin::default())
        .add_plugins(bevy_asset::AssetPlugin::default())
        .add_plugins(bevy_render::RenderPlugin::default())
        .add_plugins(bevy_render::texture::ImagePlugin::default())

        // causes crash
        .add_plugins(bevy_core_pipeline::CorePipelinePlugin)

        .run();
}

What went wrong

The program crashes after a few seconds with the error:

error: process didn't exit successfully: `target\debug\bevy_crash.exe` (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)
@Weihnachtsbaum Weihnachtsbaum added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels May 28, 2024
@alice-i-cecile
Copy link
Member

Are you able to run the examples of 'wgpu' correctly? It looks like this is likely to be a hardware or driver issue.

@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen S-Needs-Investigation This issue requires detective work to figure out what's going wrong C-Machine-Specific This bug is isolated to specific hardware or driver configurations and removed S-Needs-Triage This issue needs to be labelled labels May 28, 2024
@Weihnachtsbaum
Copy link
Author

Some examples work fine.
Many of the examples generate these warnings but still work:

[2024-05-28T18:30:04Z WARN  wgpu_core::instance] Missing downlevel flags: DownlevelFlags(VERTEX_AND_INSTANCE_INDEX_RESPECTS_RESPECTIVE_FIRST_VALUE_IN_INDIRECT_DRAW)
    The underlying API or device in use does not support enough features to be a fully compliant implementation of WebGPU. A subset of the features can still be used. If you are running this program on native and not in a browser and wish to limit the features you use to the supported subset, call Adapter::downlevel_properties or Device::downlevel_properties to get a listing of the features the current platform supports.
[2024-05-28T18:30:04Z WARN  wgpu_core::instance] DownlevelCapabilities {
        flags: DownlevelFlags(
            COMPUTE_SHADERS | FRAGMENT_WRITABLE_STORAGE | INDIRECT_EXECUTION | BASE_VERTEX | READ_ONLY_DEPTH_STENCIL | NON_POWER_OF_TWO_MIPMAPPED_TEXTURES | CUBE_ARRAY_TEXTURES | COMPARISON_SAMPLERS | INDEPENDENT_BLEND | VERTEX_STORAGE | ANISOTROPIC_FILTERING | FRAGMENT_STORAGE | MULTISAMPLED_SHADING | DEPTH_TEXTURE_AND_BUFFER_COPIES | WEBGPU_TEXTURE_FORMAT_SUPPORT | BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED | UNRESTRICTED_INDEX_BUFFER | FULL_DRAW_INDEX_UINT32 | DEPTH_BIAS_CLAMP | VIEW_FORMATS | UNRESTRICTED_EXTERNAL_TEXTURE_COPIES | SURFACE_VIEW_FORMATS | NONBLOCKING_QUERY_RESOLVE,
        ),
        limits: DownlevelLimits,
        shader_model: Sm5,
    }

The repeated_compute example also generates these warnings:

[2024-05-28T18:37:55.955682900Z WARN  wgpu_hal::auxil::dxgi::exception] Process is terminating. Using simple reporting. Please call ReportLiveObjects() at runtime for standard reporting.
[2024-05-28T18:37:55.958813500Z WARN  wgpu_hal::auxil::dxgi::exception] Live Producer at 0x0000029E2618D9C8, Refcount: 44.
[2024-05-28T18:37:55.959932900Z WARN  wgpu_hal::auxil::dxgi::exception]         Live Object at 0x0000029E260D8E90, Refcount: 0.
-- snip --
[2024-05-28T18:37:56.049361800Z WARN  wgpu_hal::auxil::dxgi::exception] Live                         Object :     62

Only the conservative_raster example dosn't work. It generates this error:

error: process didn't exit successfully: `target\debug\wgpu-examples.exe conservative_raster` (exit code: 101)

@alice-i-cecile
Copy link
Member

alice-i-cecile commented May 28, 2024

Awesome, thanks a ton for the investigation. I think the problem here is likely us escalating the warnings to a panic. The next step would be figuring out where that's going on, and then seeing if we can fail more gracefully.

@Weihnachtsbaum
Copy link
Author

Weihnachtsbaum commented May 29, 2024

I tried to find the specific part of CorePipelinePlugin's build function that causes the error by removing everything that works fine. I ended up with this:

        load_internal_asset!(
            app,
            FULLSCREEN_SHADER_HANDLE,
            "fullscreen_vertex_shader/fullscreen.wgsl",
            Shader::from_wgsl
        );
        app.add_plugins(CopyDeferredLightingIdPlugin);

If I either remove the load_internal_asset! call or not add CopyDeferredLightingIdPlugin, the error disappears, so the problem is somewhere in there.

@xangelix
Copy link

@Weihnachtsbaum could you kindly check if you experience this same issue on the latest stable version of rust? I'm tracing an issue that may be related to yours.

@Weihnachtsbaum
Copy link
Author

@xangelix it works fine on the latest stable version (1.78.0)

@xangelix
Copy link

@Weihnachtsbaum great! Could you also check nightly-2024-04-17 and nightly-2024-04-18?
I believe nightly-2024-04-18 is where things go wrong.

@Weihnachtsbaum
Copy link
Author

Weihnachtsbaum commented May 30, 2024

@xangelix that's correct, nightly-2024-04-17 works and nightly-2024-04-18 doesn't

@xangelix
Copy link

xangelix commented May 30, 2024

Thanks! I unfortunately don't know enough about bevy/wgpu/rust/windows internals and don't have enough time to probably go any further, but nightly-2024-04-17 seems to work for now. Hopefully this helps someone else narrow the issue down quicker.

It appears this issue only concerns Windows builds (including cross-compilation with mingw) on nightly-2024-04-18 or greater. I have the same issue on bevy 0.13.2 and the current main branch.

Notably, I have the logs you described on my side in BOTH the working and non-working nightly versions:

[2024-05-30T16:26:34Z WARN  wgpu_hal::dx12::shader_compilation::dxc] Failed to load dxil.dll. Defaulting to FXC instead: Failed to load library "dxil.dll": LoadLibraryExW { source: Os { code: 126, kind: Uncategorized, message: "The specified module could not be found." } }
[2024-05-30T16:26:34Z WARN  wgpu_hal::gles::adapter] Returned GL context is 1.1, when 3.3+ is needed
[2024-05-30T16:26:34Z INFO  wgpu_core::instance] Adapter Dx12 AdapterInfo { name: "Microsoft Basic Render Driver", vendor: 5140, device: 140, device_type: Cpu, driver: "", driver_info: "", backend: Dx12 }
[2024-05-30T16:26:34Z WARN  wgpu_core::instance] Missing downlevel flags: DownlevelFlags(VERTEX_AND_INSTANCE_INDEX_RESPECTS_RESPECTIVE_FIRST_VALUE_IN_INDIRECT_DRAW)
    The underlying API or device in use does not support enough features to be a fully compliant implementation of WebGPU. A subset of the features can still be used. If you are running this program on native and not in a browser and wish to limit the features you use to the supported subset, call Adapter::downlevel_properties or Device::downlevel_properties to get a listing of the features the current platform supports.
[2024-05-30T16:26:34Z WARN  wgpu_core::instance] DownlevelCapabilities {
        flags: DownlevelFlags(
            COMPUTE_SHADERS | FRAGMENT_WRITABLE_STORAGE | INDIRECT_EXECUTION | BASE_VERTEX | READ_ONLY_DEPTH_STENCIL | NON_POWER_OF_TWO_MIPMAPPED_TEXTURES | CUBE_ARRAY_TEXTURES | COMPARISON_SAMPLERS | INDEPENDENT_BLEND | VERTEX_STORAGE | ANISOTROPIC_FILTERING | FRAGMENT_STORAGE | MULTISAMPLED_SHADING | DEPTH_TEXTURE_AND_BUFFER_COPIES | WEBGPU_TEXTURE_FORMAT_SUPPORT | BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED | UNRESTRICTED_INDEX_BUFFER | FULL_DRAW_INDEX_UINT32 | DEPTH_BIAS_CLAMP | VIEW_FORMATS | UNRESTRICTED_EXTERNAL_TEXTURE_COPIES | SURFACE_VIEW_FORMATS | NONBLOCKING_QUERY_RESOLVE,
        ),
        limits: DownlevelLimits,
        shader_model: Sm5,
    }

I also never get the

error: process didn't exit successfully: `target\debug\bevy_crash.exe` (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)

error you described. In fact, I don't get any error at all. The program just closes after a few successful ticks, never drawing more than a black screen.

I would be glad to collect any additional logs/environment details if it helps.

@Weihnachtsbaum
Copy link
Author

Are we sure that the problem lies within bevy or could it be in rustc?

@xangelix
Copy link

xangelix commented May 30, 2024

It could definitely be rustc afaik, but I would expect behavior changing in an unstable feature used by a bevy dependency (like wgpu) to also be likely. rustc by itself might actually be unlikely given the issue is still present 6 weeks later.

If you have time, a few ideas come to mind, but I'm really not the best person to ask.

  • Are these "Missing downlevel flags" messages actually related to the issue? When do they appear? My windows VM uses a CPU renderer, is this specific to the problem? It does appear specific to Windows, which tells me GPU/dx12 seems likely? (is bevy vulkan compatible with windows? I don't think I can test bevy vulkan in windows with my CPU driver)
  • What changes on nightly features were made between nightly-2024-04-17 and nightly-2024-04-18 (be careful with exact branch/compile times)? Does this issue exist on the 1.79.0 beta? (I believe the beta disables all nightly features, so you could then know if it was a stable change or an unstable feature change made between those two times).
  • I can get log messages out of the first few game update ticks, and then it crashes. What system would crash/close here?

I'm also not especially familiar with rust or c development on windows, it's quite possible I didn't get any crash error because I don't have some windows debugging options that I don't know about enabled outside of rust.

The bevy devs will certainly have better intuition here.

@Weihnachtsbaum
Copy link
Author

I just tested it out, it also crashes in 1.79.0-beta.7 (9ca20fadf 2024-05-22). Using nightly-2024-04-17 or prior works for now but as the readme says:

Bevy relies heavily on improvements in the Rust language and compiler. As a result, the Minimum Supported Rust Version (MSRV) is generally close to "the latest stable release" of Rust.

so in the future this won't be possible anymore.

Unfortunately, I am a Rust and Bevy beginner and don't think I will be very helpful in fixing this issue.

@xangelix
Copy link

xangelix commented Jun 3, 2024

thought I'd give it another go after the winit v0.30 merge, unfortunately the problem still exists on the latest nightly and bb51635

@xangelix
Copy link

xangelix commented Jun 14, 2024

@Weihnachtsbaum looks like things are happening! :) rust-lang/rust#126442
gfx-rs/wgpu@d309bba should fix this

@Weihnachtsbaum
Copy link
Author

@xangelix Great! Do you know when we can expect this to be included in bevy?

@alice-i-cecile
Copy link
Member

The fix is merged by wgpu here: gfx-rs/wgpu#5812

That should be going out in a new release shortly, and #13186 will grab it for 0.14 for sure. I believe they're also backporting it, which would be nice.

@alice-i-cecile alice-i-cecile added O-Windows Specific to the Windows desktop operating system S-Blocked This cannot move forward until something else changes and removed C-Machine-Specific This bug is isolated to specific hardware or driver configurations S-Needs-Investigation This issue requires detective work to figure out what's going wrong labels Jun 14, 2024
@alice-i-cecile alice-i-cecile added this to the 0.14 milestone Jun 14, 2024
@djeedai
Copy link
Contributor

djeedai commented Jun 21, 2024

Hanabi CI is hitting those "Missing downlevel flags" too: https://github.com/djeedai/bevy_hanabi/actions/runs/9609820286/job/26505417917, as well as example crashes:

error: process didn't exit successfully: `target\debug\examples\activate.exe` (exit code: 0xc000041d)

@alice-i-cecile
Copy link
Member

This is not yet fixed: https://github.com/gfx-rs/wgpu/releases/tag/v0.20.1 does not include the relevant PR.

@alice-i-cecile
Copy link
Member

https://github.com/gfx-rs/wgpu/releases/tag/v0.20.2 and wgpu is upgraded. Closing as fixed, thanks y'all!

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 C-Bug An unexpected or incorrect behavior O-Windows Specific to the Windows desktop operating system S-Blocked This cannot move forward until something else changes
Projects
None yet
Development

No branches or pull requests

4 participants