fn check(b: *Bucket, s: *SafeAllocator) void b: *Buckets: *SafeAllocator240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259 fn check(b: *Bucket, s: *SafeAllocator) void {
var footer = b.lastAlloc(s, b.fill).?;
while (true) {
const modify = @atomicLoad(
AllocFooter.Modify,
&footer.modify,
// The only possible value should be `.freed` since `b.alloc_count`
// has been loaded with `.acquire`. However, another thread may be trying to
// modify the allocation after it is freed and so the other thread is going
// to panic even if this thread still sees `.freed`.
.unordered,
).storedXor(&footer.modify);
if (modify != .freed or footer.actualChecksum(s) != footer.checksum ^ s.canary) {
panic("corrupted footer metadata in bucket at *{x}", .{@intFromPtr(&footer)});
}
s.checkFreed(footer);
footer = footer.bucketPrev(b, s) orelse break;
}
}
Checks that no writes after frees were performed.
Assumes
b.alloc_counthas been loaded with.acquireordering.