removing lots of statics crash
Posted: Thu Apr 09, 2020 10:51 pm
Hi!
I have a mysterious crash that I'm unable to track down the reason for. This is the relevant part of the callstack:
System.Private.CoreLib.dll!System.Diagnostics.DebugProvider.Fail(string message, string detailMessage) Line 32
BepuUtilities.dll!BepuUtilities.Memory.Buffer<BepuPhysics.Collidables.Collidable>.this[int].get(int index) Line 56
BepuPhysics.dll!BepuPhysics.Statics.RemoveAt(int index) Line 184
BepuPhysics.dll!BepuPhysics.Statics.Remove(int handle) Line 224
(The assert triggers because HandleToIndex[handle] is -1)
I've verified that the handle has been added properly and is not removed twice. I'm removing a whole bunch of statics in a loop and it fails after deleting a handful of them; it's deterministic and reproable.
Understanding the statics tree and handle/index thing is tricky; but looking at Statics.RemoveAt it seems it's deleting the next-to-last leaf, causing the last leaf to move up into its place.. but leaving HandleToIndex for the handle pointing at the old location; now outside the tree.
If I misunderstand the code and it's all fine; what could cause this crash and how can I figure out what's happening?
Thanks again for your great support of this library!
--michael
I have a mysterious crash that I'm unable to track down the reason for. This is the relevant part of the callstack:
System.Private.CoreLib.dll!System.Diagnostics.DebugProvider.Fail(string message, string detailMessage) Line 32
BepuUtilities.dll!BepuUtilities.Memory.Buffer<BepuPhysics.Collidables.Collidable>.this[int].get(int index) Line 56
BepuPhysics.dll!BepuPhysics.Statics.RemoveAt(int index) Line 184
BepuPhysics.dll!BepuPhysics.Statics.Remove(int handle) Line 224
(The assert triggers because HandleToIndex[handle] is -1)
I've verified that the handle has been added properly and is not removed twice. I'm removing a whole bunch of statics in a loop and it fails after deleting a handful of them; it's deterministic and reproable.
Understanding the statics tree and handle/index thing is tricky; but looking at Statics.RemoveAt it seems it's deleting the next-to-last leaf, causing the last leaf to move up into its place.. but leaving HandleToIndex for the handle pointing at the old location; now outside the tree.
If I misunderstand the code and it's all fine; what could cause this crash and how can I figure out what's happening?
Thanks again for your great support of this library!
--michael