Skip to content

The current BlockEntity system can crash on unloading #1453

@IntegratedQuantum

Description

@IntegratedQuantum

I think the current approach to free the data is not viable.
Right now the following happens:
On data removal, a swap remove is performed. This is achieved by reassigning the index in its source location, in the per chunk hashmap.
This however produces race conditions like this:

  1. ChunkMesh A gets out of render distance, so its refcount is reduced by 1, however it is still used somewhere else, so its BlockEntity data is not cleared.
  2. ChunkMesh B gets out of render distance, it's refcount is now 0 so its BlockEntity data is freed.
  3. While freeing a swapRemove happens, that swaps one of the block entities of Chunk A
  4. The system tries to get Chunk A using the mesh_storage, but it doesn't have the chunk anymore because it's already out of render distance

I think the simplest solution would be avoid any remapping of indices and just use a SparseSet #1414 to ensure denseness.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething isn't working in the intended wayengine

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions