[ModApi] MyVoxelGeometry.GetCellLineIntersectionOctree() is Not Thread-Safe

Aristeas shared this bug 34 hours ago
Submitted

Because a single overlap element cache list is used between all instances of MyVoxelGeometry and calls to GetCellLineIntersectionOctree(), voxel intersection checks cannot be safely multithreaded. This impacts (MyVoxelGeometry).Intersect(), both (MyVoxelBase).GetIntersectionWithLine() variants, and likely other methods as well.


Possible fixes would be to use an object pool (like is used elsewhere) or allow modders to supply their own cache list, but you (the poor developer reading this) would know better than I.


Example exception w/ stack:

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at Sandbox.Engine.Voxels.MyVoxelGeometry.GetCellLineIntersectionOctree(Nullable`1& result, Line& modelSpaceLine, Nullable`1& minDistanceUntilNow, CellData cachedDataCell, IntersectionFlags flags)
   at Sandbox.Engine.Voxels.MyVoxelGeometry.Intersect(Line& localLine, MyIntersectionResultLineTriangle& result, IntersectionFlags flags)
   at Sandbox.Game.Entities.MyVoxelBase.GetIntersectionWithLine(LineD& worldLine, Nullable`1& t, IntersectionFlags flags)

Leave a Comment
 
Attach a file
Access denied