Using mimalloc with bevy reveals unsoundness.
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## Bevy version
0.15.3
## Relevant system information
- Windows 11
- cargo 1.86.0-nightly (ce948f461 2025-02-14)
## What you did
Compiled and ran the following test, **with dynamic_linking enabled**:
```rs
//! A simple 3D scene with light shining over a cube sitting on a plane.
use bevy::prelude::*;
use mimalloc::MiMalloc;
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;
fn main() {
let mut a = App::new();
a.add_plugins(DefaultPlugins);
std::mem::drop(a); // exercise allocating a bit.
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.run();
}
/// set up a simple 3D scene
fn setup(
mut commands: Commands,
mut meshes: ResMut>,
mut materials: ResMut>,
) {
// circular base
commands.spawn((
Mesh3d(meshes.add(Circle::new(4.0))),
MeshMaterial3d(materials.add(Color::WHITE)),
Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)),
));
// cube
commands.spawn((
Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0))),
MeshMaterial3d(materials.add(Color::srgb_u8(124, 144, 255))),
Transform::from_xyz(0.0, 0.5, 0.0),
));
// light
commands.spawn((
PointLight {
shadows_enabled: true,
..default()
},
Transform::from_xyz(4.0, 8.0, 4.0),
));
// camera
commands.spawn((
Camera3d::default(),
Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
));
}
```
For ease of reproduction, a repo with settings necessary to make dylink work on windows is here: https://github.com/moonheart08/bevy-crash-repro
## What went wrong
Immediate segmentation fault.
Contributor guide
Research direction
Start with the linked bevy-crash-repro repository and its Windows dynamic_linking setup, then run the provided example with mimalloc enabled. Focus on the immediate segmentation fault after dropping the first App and determine what change is needed for the reproduction to run without crashing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100