Skip to content

Conversation

@grind086
Copy link
Contributor

Objective

Fixes #22152

Solution

From the safety notes on DynamicBundle::apply_effect:

If any part of ptr is to be accessed in this function, it must not be dropped at any point in get_components.

The MovingPtr here is dropped when it goes out of scope, so the assume_init here is invalid. This is fixed by mem::forget-ing the pointer in get_components, which will leave the allocation intact for apply_effect.

Testing

Using the example from the issue, the logs are correct after this patch

@alice-i-cecile alice-i-cecile added this to the 0.18 milestone Dec 17, 2025
@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-ECS Entities, components, systems, and events P-Unsound A bug that results in undefined compiler behavior S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Dec 17, 2025
@cart cart enabled auto-merge December 17, 2025 02:32
@cart cart added this pull request to the merge queue Dec 17, 2025
Merged via the queue into bevyengine:main with commit e203add Dec 17, 2025
45 checks passed
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-Unsound A bug that results in undefined compiler behavior S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Memory leak/corruption with experimental ui_widget observe() function

5 participants