-
Notifications
You must be signed in to change notification settings - Fork 2
Description
We could include a mutable field in each AllocArray tracking whether it is active, and a vector in the bumper allocator object collecting all of the allocated arrays. Then when we reset the bump, we loop through and mark each array as inactive (which would cause eg getindex to error if called on it), and empty the list.
I think this would prevent “use after free” errors pretty comprehensively (in the serial case), possibly at the cost of some performance. It could be done as secondary types though, allowing debugging/testing with the safe version, then switching to the unchecked one for speed.
For concurrency safety, maybe some mechanism could be used for the resetting function to get exclusive access to each of the arrays in order to flip their activity bits. Eg if each array holds a lock? Or something where operations on the array don’t contest each other, but do contest with the resetter. Then we could empty the buffer once every array has been toggled inactive.