Compiler got panicked while using Bevy.
Open
Nobody has claimed this yet.
C-bug
I-ICE
S-needs-info
S-needs-repro
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use bevy::prelude::*;
use bevy::sprite::Wireframe2dPlugin;
const WINDOW_WIDTH: f32 = 960.0;
const WINDOW_HEIGHT: f32 = 540.0;
const TILE_SIZE: f32 = 50.0;
#[derive(Component)]
struct DebugLog {
buf: String,
}
#[derive(Component)]
struct Pawn;
fn setup(
mut windows: Query<&mut Window>,
mut cmds: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<ColorMaterial>>,
mut texture_atlas_layouts: ResMut<Assets<TextureAtlasLayout>>,
asset_server: Res<AssetServer>,
) {
// window
let mut window = windows.single_mut();
window.resolution.set(WINDOW_WIDTH, WINDOW_HEIGHT);
window.resizable = false;
window.title = "BEVY TITLE".to_string();
// camera
cmds.spawn(Camera2d);
// tile
for i in 0..10 {
for j in 0..10 {
let i_f = i as f32;
let j_f = j as f32;
cmds.spawn((
Mesh2d(meshes.add(Rectangle::new(TILE_SIZE, TILE_SIZE))),
MeshMaterial2d(materials.add(Color::srgba(i_f * 0.1, j_f * 0.1, 1.0, 1.0))),
Transform::from_xyz(50.0 * i_f, 50.0 * j_f, 0.0),
));
}
}
// pawn
cmds.spawn((
Sprite {
image: asset_server.load("Pawn.png"),
texture_atlas: Some(TextureAtlas {
layout: texture_atlas_layouts.add(TextureAtlasLayout::from_grid(UVec2::splat(64), 10, 4, None, None)),
index: 1,
}),
..default()
},
Transform::from_xyz(0.0, 0.0, 0.0).with_scale(Vec3::splat(0.5)),
Pawn
));
}
fn move_camera(
mut debug_text_query: Query<&mut DebugLog>,
mut camera_query: Query<&mut Transform, With<Camera2d>>,
keys: Res<ButtonInput<KeyCode>>,
time: Res<Time>,
) {
// Vary the movement amount by key detection
let mut dx: f32 = 0.0;
let mut dy: f32 = 0.0;
if keys.pressed(KeyCode::KeyW) { dy += 100.0 }
if keys.pressed(KeyCode::KeyA) { dx -= 100.0 }
if keys.pressed(KeyCode::KeyS) { dy -= 100.0 }
if keys.pressed(KeyCode::KeyD) { dx += 100.0 }
if keys.pressed(KeyCode::ShiftLeft) {
dx *= 2.0;
dy *= 2.0;
}
let mut camera = camera_query.single_mut();
camera.translation.x += dx * time.delta_secs();
camera.translation.y += dy * time.delta_secs();
// debug!
let mut debug_text = match debug_text_query.get_single_mut() {
Ok(e1) => e1,
_ => return
};
debug_text.buf = format!("{}\nCamera: x:{:.2} y:{:.2}", debug_text.buf, camera.translation.x, camera.translation.y);
}
fn display_debug_text(
mut text_entity_query: Query<&mut DebugLog>,
mut text_query: Query<&mut Text, With<DebugLog>>,
) {
let mut entity = match text_entity_query.get_single_mut() {
Ok(e) => e,
Err(_) => return
};
let mut text = text_query.single_mut();
text.0 = entity.buf.clone();
entity.buf = String::new();
}
fn hiding_debug_text(
entity_query: Query<Entity, With<DebugLog>>,
mut cmds: Commands,
asset_server: Res<AssetServer>,
keys: Res<ButtonInput<KeyCode>>,
) {
if !keys.just_pressed(KeyCode::KeyH) { return }
if let Ok(e) = entity_query.get_single() {
cmds.entity(e).despawn();
return;
}
cmds.spawn((
Text::new("--- LOG ---"),
TextFont {
font: asset_server.load("fonts/Menlo-Regular.ttf"),
..default()
},
Node {
align_self: AlignSelf::Start,
justify_self: JustifySelf::Start,
..default()
},
BackgroundColor(Color::BLACK),
DebugLog {
buf: "--- LOG ---".to_string(),
}
));
}
fn close_on_q(
mut commands: Commands,
window: Query<(Entity, &Window)>,
input: Res<ButtonInput<KeyCode>>,
) {
let (window, _focus) = match window.get_single() {
Ok(wf) => wf,
Err(_) => return
};
if input.just_pressed(KeyCode::KeyQ) {
commands.entity(window).despawn();
}
}
fn main() {
App::new()
.add_plugins((
DefaultPlugins.set(ImagePlugin::default_nearest()),
Wireframe2dPlugin,
))
.add_systems(Startup, setup)
.add_systems(Update, (
move_camera,
display_debug_text,
hiding_debug_text,
close_on_q,
).chain())
.run();
}
Meta
rustc --version --verbose:
rustc 1.84.1 (e71f9a9a9 2025-01-27)
binary: rustc
commit-hash: e71f9a9a98b0faf423844bf0ba7438f29dc27d58
commit-date: 2025-01-27
host: x86_64-pc-windows-msvc
release: 1.84.1
LLVM version: 19.1.5
Error output
thread 'coordinator' panicked at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58\compiler\rustc_codegen_ssa\src\back\write.rs:1662:29:
/rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58\compiler\rustc_codegen_ssa\src\back\write.rs:1662:29: worker thread panicked
Backtrace
<backtrace>
stack backtrace:
0: 0x7ffb605bbc31 - std::backtrace_rs::backtrace::dbghelp64::trace
at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58\library/std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
1: 0x7ffb605bbc31 - std::backtrace_rs::backtrace::trace_unsynchronized
at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58\library/std\src\..\..\backtrace\src\backtrace\mod.rs:66
2: 0x7ffb605bbc31 - std::sys::backtrace::_print_fmt
at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58\library/std\src\sys\backtrace.rs:66
3: 0x7ffb605bbc31 - std::sys::backtrace::impl$0::print::impl$0::fmt
at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58\library/std\src\sys\backtrace.rs:39
4: 0x7ffb605edf0a - core::fmt::rt::Argument::fmt
at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58\library/core\src\fmt\rt.rs:177
5: 0x7ffb605edf0a - core::fmt::write
at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58\library/core\src\fmt\mod.rs:1189
6: 0x7ffb605b1fd7 - std::io::Write::write_fmt<std::sys::pal::windows::stdio::Stderr>
at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58\library/std\src\io\mod.rs:1884
7: 0x7ffb605bba75 - std::sys::backtrace::BacktraceLock::print
at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58\library/std\src\sys\backtrace.rs:42
8: 0x7ffb605be993 - std::panicking::default_hook::closure$1
at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58\library/std\src\panicking.rs:268
9: 0x7ffb605be772 - std::panicking::default_hook
at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58\library/std\src\panicking.rs:295
10: 0x7ffb61b993de - strncpy
11: 0x7ffb605bf0d2 - alloc::boxed::impl$30::call
at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58\library/alloc\src\boxed.rs:1986
12: 0x7ffb605bf0d2 - std::panicking::rust_panic_with_hook
at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58\library/std\src\panicking.rs:809
13: 0x7ffb6320868f - ar_archive_writer[cbf16ec747e0c0a3]::object_reader::get_member_alignment
14: 0x7ffb632031d9 - ar_archive_writer[cbf16ec747e0c0a3]::object_reader::get_member_alignment
15: 0x7ffb63201ec9 - ar_archive_writer[cbf16ec747e0c0a3]::object_reader::get_member_alignment
16: 0x7ffb6329d5bd - rustc_middle[77599409a02e487e]::util::bug::bug_fmt
17: 0x7ffb6327df8d - <rustc_middle[77599409a02e487e]::ty::consts::Const>::to_valtree
18: 0x7ffb6327dda6 - <rustc_middle[77599409a02e487e]::ty::consts::Const>::to_valtree
19: 0x7ffb6329d4f2 - rustc_middle[77599409a02e487e]::util::bug::bug_fmt
20: 0x7ffb606880c4 - rustc_interface[aab1116b3078e23b]::proc_macro_decls::proc_macro_decls_static
21: 0x7ffb5d648f4d - llvm::DenseMap<llvm::StructType * __ptr64,llvm::detail::DenseSetEmpty,llvm::IRMover::StructTypeKeyInfo,llvm::detail::DenseSetPair<llvm::StructType * __ptr64> >::~DenseMap<llvm::StructType * __ptr64,llvm::detail::DenseSetEmpty,llvm::IRMover::StructTypeKeyIn
22: 0x7ffb5d654d4a - llvm::DenseMap<llvm::StructType * __ptr64,llvm::detail::DenseSetEmpty,llvm::IRMover::StructTypeKeyInfo,llvm::detail::DenseSetPair<llvm::StructType * __ptr64> >::~DenseMap<llvm::StructType * __ptr64,llvm::detail::DenseSetEmpty,llvm::IRMover::StructTypeKeyIn
23: 0x7ffb605d0d9d - alloc::boxed::impl$28::call_once
at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58\library/alloc\src\boxed.rs:1972
24: 0x7ffb605d0d9d - alloc::boxed::impl$28::call_once
at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58\library/alloc\src\boxed.rs:1972
25: 0x7ffb605d0d9d - std::sys::pal::windows::thread::impl$0::new::thread_start
at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58\library/std\src\sys\pal\windows\thread.rs:55
26: 0x7ffbdb21e8d7 - BaseThreadInitThunk
27: 0x7ffbdcebbf2c - RtlUserThreadStart
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the Bevy example with rustc 1.84.1 on Windows and capture the reported backtrace. Start by examining the compiler locations shown in rustc_codegen_ssa/src/back/write.rs:1662 and rustc_middle's Const::to_valtree, then minimize the example until the panic trigger is isolated. Done means a minimized reproduction or a confirmed compiler fix with a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100