Skip to content

#2384 Fix deleting a parent before its Parent-component children - #2385

Open
andrewgazelka wants to merge 2 commits into
SanderMertens:masterfrom
indexable-inc:fix/fini-nonfrag-childof-prefab
Open

andrewgazelka wants to merge 2 commits into
SanderMertens:masterfrom
indexable-inc:fix/fini-nonfrag-childof-prefab

Conversation

@andrewgazelka

@andrewgazelka andrewgazelka commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2384.

When a delete clears the table of a parent before the parent's (ChildOf, p) entry deletes its Parent-component children:

  • flecs_non_fragmenting_childof_move accepts a dead parent if its (ChildOf, p) record is marked for delete (it stays alive until the delete finishes). For such records it skips the prefab spawner check. That check walks the parent's own parents with ecs_get_parent, which asserts if one of them is already gone.
  • flecs_ordered_children_clear keeps EcsIdOrderedChildren on a record that is marked for delete and still has Parent children, so flecs_on_delete_clear_entities still finds and deletes them (it already kept the vector).

Tests (all fail on master): NonFragmentingChildOf.delete_parent_w_table_cleared_before_children, delete_parent_w_ordered_children_w_table_cleared_before_children and delete_parent_w_prefab_child_w_table_cleared_before_children. core, query, addons, meta, script and collections pass on macOS arm64. The script from the issue now exits cleanly.

distr/flecs_no_addons.* on master were already out of date with src. Only this change is applied to them.

…ponent children

When a delete clears the table of a parent before the ChildOf record of
the parent deletes its children, the children were deleted with a dead
parent (assert in flecs_non_fragmenting_childof_move), or leaked if the
parent had OrderedChildren (flecs_ordered_children_clear dropped the
flag of the marked record, so cleanup skipped the children).
… parent being deleted

The check walks the parents of the parent with ecs_get_parent, which
asserts when one of them was already deleted in the same delete.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deleting a parent before its Parent-component children asserts in flecs_non_fragmenting_childof_move (or leaks them with OrderedChildren)

1 participant