Skip to content

Minimal Setup Causes Segfault #3449

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
ztroop opened this issue Dec 27, 2021 · 7 comments
Closed

Minimal Setup Causes Segfault #3449

ztroop opened this issue Dec 27, 2021 · 7 comments
Labels
A-Rendering Drawing game state to the screen C-Startup A crash that occurs when first attempting to run a Bevy app O-Linux Specific to the Linux desktop operating system

Comments

@ztroop
Copy link

ztroop commented Dec 27, 2021

Bevy version

[dependencies]
bevy = "0.5.0"

Operating system & version

Linux 5.4.0-89-generic Ubuntu SMP Fri Sep 24 14:50:10 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Codename: focal

active toolchain
----------------
stable-x86_64-unknown-linux-gnu (default)
rustc 1.57.0 (f1edd0429 2021-11-29)

What you did

use bevy::prelude::*;

fn setup(mut commands: Commands) {
    commands.spawn_bundle(OrthographicCameraBundle::new_2d());
}

fn main() {
    App::build()
    .add_startup_system(setup.system())
    .add_plugins(DefaultPlugins).run();
}

What you expected to happen

Running the app should get an empty window.

What actually happened

[1]    37994 segmentation fault (core dumped)  RUST_BACKTRACE=full cargo run
@ztroop ztroop added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Dec 27, 2021
@alice-i-cecile
Copy link
Member

[1] 37994 segmentation fault (core dumped) RUST_BACKTRACE=full cargo run

Thanks for the report :) Could you send us the backtrace? And after that, could you test on main? Rendering is a likely candidate, so it may be already fixed.

@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen C-Startup A crash that occurs when first attempting to run a Bevy app O-Linux Specific to the Linux desktop operating system and removed S-Needs-Triage This issue needs to be labelled C-Bug An unexpected or incorrect behavior labels Dec 27, 2021
@ztroop
Copy link
Author

ztroop commented Dec 27, 2021

I'm not seeing any backtrace. I tried export RUST_BACKTRACE=full before execution as well. I'm trying bevy = { git = "https://github.com/bevyengine/bevy", branch = "main" } as suggested. rust_analyzer is now complaining about:

error[E0599]: no function or associated item named `build` found for struct `bevy::prelude::App` in the current scope
 --> src/main.rs:8:10
  |
8 |     App::build()
  |          ^^^^^ function or associated item not found in `bevy::prelude::App`

I know the API is subject to change, but the official docs show this usage as well and I'm a bit confused.

@alice-i-cecile
Copy link
Member

I'm not seeing any backtrace.

Alright, hmm 🤔

I know the API is subject to change, but the official docs show this usage as well and I'm a bit confused.

Ah, those docs are for our latest release, 0.5. That's changed on main; you can build the updated docs locally with cargo doc --open. Try:

use bevy::prelude::*;

fn setup(mut commands: Commands) {
    commands.spawn_bundle(OrthographicCameraBundle::new_2d());
}

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

If you run into "could not select a matching version" errors, delete your Cargo.lock and use cargo clean before recompiling.

@ztroop
Copy link
Author

ztroop commented Dec 27, 2021

Okay, I can view the updated documentation with cargo doc --open. I tried the code you shared and I have no complaints from rust-analyzer. I removed Cargo.lock and ran cargo clean. However, I see some backtrace information. :)

2021-12-27T18:19:53.312551Z  INFO winit::platform_impl::platform::x11::window: Guessed window scale factor: 1    
2021-12-27T18:19:53.430025Z  INFO bevy_render::renderer: AdapterInfo { name: "Intel(R) UHD Graphics (CML GT2)", vendor: 32902, device: 39745, device_type: IntegratedGpu, backend: Vulkan }
2021-12-27T18:19:53.874243Z ERROR wgpu_hal::vulkan::instance: VALIDATION [VUID-VkRenderPassBeginInfo-framebuffer-03210 (0x0)]
        VkRenderPassBeginInfo: Image view #0 created from an image with usage set as 0x12, but image info #0 used to create the framebuffer had usage set as 0x10 The Vulkan spec states: If framebuffer was created with a VkFramebufferCreateInfo::flags value that included VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT, each element of the pAttachments member of a VkRenderPassAttachmentBeginInfo structure included in the pNext chain must be a VkImageView of an image created with a value of VkImageCreateInfo::usage equal to the usage member of the corresponding element of VkFramebufferAttachmentsCreateInfo::pAttachments used to create framebuffer (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-VkRenderPassBeginInfo-framebuffer-03210)    
2021-12-27T18:19:53.876000Z ERROR wgpu_hal::vulkan::instance:   objects: (type: RENDER_PASS, hndl: 0x3c000000003c, name: ?)    
2021-12-27T18:19:53.878555Z ERROR wgpu_hal::vulkan::instance: VALIDATION [VUID-VkRenderPassBeginInfo-framebuffer-03209 (0x0)]
        VkRenderPassBeginInfo: Image view #1 created from an image with flags set as 0x400, but image info #1 used to create the framebuffer had flags set as 0x0 The Vulkan spec states: If framebuffer was created with a VkFramebufferCreateInfo::flags value that included VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT, each element of the pAttachments member of a VkRenderPassAttachmentBeginInfo structure included in the pNext chain must be a VkImageView of an image created with a value of VkImageCreateInfo::flags equal to the flags member of the corresponding element of VkFramebufferAttachmentsCreateInfoKHR::pAttachments used to create framebuffer (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-VkRenderPassBeginInfo-framebuffer-03209)    
2021-12-27T18:19:53.880031Z ERROR wgpu_hal::vulkan::instance:   objects: (type: RENDER_PASS, hndl: 0x3c000000003c, name: ?)    
[1]    49807 segmentation fault (core dumped)  cargo run

I did run export RUST_BACKTRACE=full beforehand, so that's why it's not in-line with cargo run. I'm not entirely sure what this error means, but I have a feeling it has to do with my graphics configuration or hardware. I'm providing some additional details:

ztroop in ~/projects/bevy-snake-ng on master ● λ lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation UHD Graphics (rev 02)
ztroop in ~/projects/bevy-snake-ng on master ● λ sudo lshw -C display
  *-display
       description: VGA compatible controller
       product: UHD Graphics
       vendor: Intel Corporation
       physical id: 2
       bus info: pci@0000:00:02.0
       version: 02
       width: 64 bits
       clock: 33MHz
       capabilities: pciexpress msi pm vga_controller bus_master cap_list rom
       configuration: driver=i915 latency=0
       resources: irq:129 memory:b0000000-b0ffffff memory:a0000000-afffffff ioport:4000(size=64) memory:c0000-dffff

@alice-i-cecile
Copy link
Member

I'm not entirely sure what this error means, but I have a feeling it has to do with my graphics configuration or hardware

Precisely; our rendering solution is failing on your hardware / driver combination. Thanks for the information about your device; that's extremely helpful for us.

It's using your integrated GPU: I presume your machine does not have a dedicated graphics card?

I would try updating your graphics drivers, but if that fails this is likely an upstream bug in wgpu; could you test their examples? If that fails, please open an issue there and link this issue. They've been very responsive, so fingers crossed the fix should be easy.

In the meantime, you should be able to get started with Bevy by disabling default features (or excluding rendering from your plugin set), on either 0.5 or main. No graphics, but that may or may not be an issue depending on what you'd like to make.

bevy = { git = "https://github.com/bevyengine/bevy/",  default-features = false, features = ["audio"]}

Here I've manually enabled the "audio" feature.

If you're feeling particularly adventurous, Bevy is able to run on CPU-emulated graphics cards: #3358 is the PR that enables our CI to run on machines without a GPU.

@ztroop
Copy link
Author

ztroop commented Dec 27, 2021

It's using your integrated GPU: I presume your machine does not have a dedicated graphics card?

Yes, it's a Lenovo laptop. No dedicated graphics card.

I would try updating your graphics drivers, but if that fails this is likely an upstream bug in wgpu; could you test their examples? If that fails, please open an issue there and link this issue.

Yes, it looks like I can't run some of their examples. Similar output.

In the meantime, you should be able to get started with Bevy by disabling default features

Graphics is definitely something I wanted to play with, but CPU emulation might be a decent workaround.

@ztroop
Copy link
Author

ztroop commented Dec 29, 2021

Hello! I wanted to update this ticket with my findings. The cause was definitely related to mesa/vulkan on the system. I tried using a newer, upstream kernel and graphics drivers / modules. Unfortunately, I still wasn't able to get things working. I did read that i915 functions better with the newer upstream software. I decided to upgrade my system to a rolling release Linux distribution. I'm now able to get things working without any issues.

I suppose that's a bit of a cop out, but it solves the immediate problem and allows me to move forward.

@ztroop ztroop closed this as completed Dec 29, 2021
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-Startup A crash that occurs when first attempting to run a Bevy app O-Linux Specific to the Linux desktop operating system
Projects
None yet
Development

No branches or pull requests

2 participants