Closed lenesxy closed 2 months ago
ThreadA:VoxelData::get_blocks_grid() will read lock [data_lod.map_lock] and the reference_area_block_coords() will read lock [data_lod.spatial_lock] in sl->lock_read(). Should Spatial lock need to be locked first here?
If both the map and the spatial lock need to be locked (i.e access to chunks AND voxels inside the chunks are both needed), then spatial lock must be locked first, and the map second while the spatial lock is acquired.
VoxelData::get_blocks_grid
and reference_area_block_coords
look wrong because they do the opposite, the map is locked first and spatial lock second, hence the possible deadlock.
I don't recall why it ended up this way, but should probably be swapped.
Should be fixed in 5da379d10004c6726ae43f7d43cfc6d5e3bc797e
When applicable, please describe your setup:
Screenshot ThreadA:
ThreadB:
MainThread:
ThreadA:VoxelData::get_blocks_grid() will read lock [data_lod.map_lock] and the reference_area_block_coords() will read lock [data_lod.spatial_lock] in sl->lock_read(). Should Spatial lock need to be locked first here? ThreadB:VoxelData::unload_blocks() will write lock [lod.spatial_lock] and then write lock [lod.map_lock]
This may cause dead lock