Skip to content

Conversation

@ElliottjPierce
Copy link
Contributor

Objective

#18670 introduced a small but fatal issue with batch spawning. Previous tests did not catch this bug because they tested alloc and alloc_many separately.

Solution

  • Fix an off by one math mistake in FreeBufferIterator::next.
  • Fix the part where you need to ptr.add(index) if you want the element at index. Whoops.
  • Add a test to catch these issues next time

Testing

  • CI
  • One new test
  • This was originally found here, and the reproduction crashes on main but is fine on this branch.

@ElliottjPierce ElliottjPierce added C-Bug An unexpected or incorrect behavior A-ECS Entities, components, systems, and events P-Crash A sudden unexpected crash S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 23, 2026
@alice-i-cecile alice-i-cecile added this to the 0.19 milestone Jan 23, 2026
@mockersf mockersf added this pull request to the merge queue Jan 23, 2026
Merged via the queue into bevyengine:main with commit 67db8e8 Jan 23, 2026
47 checks passed
beicause pushed a commit to beicause/bevy that referenced this pull request Jan 24, 2026
# Objective

bevyengine#18670 introduced a small but fatal issue with batch spawning. Previous
tests did not catch this bug because they tested `alloc` and
`alloc_many` separately.

## Solution

- Fix an off by one math mistake in `FreeBufferIterator::next`.
- Fix the part where you need to `ptr.add(index)` if you want the
element at `index`. Whoops.
- Add a test to catch these issues next time

## Testing

- CI
- One new test
- This was originally found
[here](https://discord.com/channels/691052431525675048/749335865876021248/1464359124950319114),
and the reproduction crashes on main but is fine on this branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior P-Crash A sudden unexpected crash S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants