Skip to content

Fix: Add warning for meshes with no vertices in MeshAllocator#24960

Open
Tatsuya0330 wants to merge 4 commits into
bevyengine:mainfrom
Tatsuya0330:issue_24874
Open

Fix: Add warning for meshes with no vertices in MeshAllocator#24960
Tatsuya0330 wants to merge 4 commits into
bevyengine:mainfrom
Tatsuya0330:issue_24874

Conversation

@Tatsuya0330

Copy link
Copy Markdown
Contributor

Objective

Solution

  • If a mesh contains no vertices, it now logs a WARN diagnostic message.
  • Added a corresponding guard in the data copying loop to skip empty meshes, preventing the subsequent use-after-free error previously seen in the slab allocator.

Testing

  • This change only adds a diagnostic warning and does not alter the rendering behavior. Since there is no existing infrastructure for asserting log output in bevy_render, I did not add a unit test for the warning itself.

Showcase

before

ERROR bevy_render::slab_allocator: Use-after-free: attempted to copy element data for an unallocated key

after

WARN bevy_render::mesh::allocator: Mesh AssetId<bevy_mesh::mesh::Mesh>{ index: 4, generation: 0} contains no vertices.

@kfc35 kfc35 added A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jul 12, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in Rendering Jul 12, 2026
use bevy_math::bounding::{Aabb2d, BoundingVolume};
use bevy_mesh::Indices;
use glam::Vec4;
use tracing::warn;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should prefer bevy_log::warn

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed it now.

@kfc35 kfc35 added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jul 13, 2026
@alice-i-cecile alice-i-cecile enabled auto-merge July 14, 2026 00:29
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-Usability A targeted quality-of-life change that makes Bevy easier to use D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

Spawning an Empty mesh results in "Use-after-free" error message

4 participants