runtime: zero freed memory

This helps to find bugs in the GC. It does have a performance impact so
it's only enabled when asserts are enabled.
This commit is contained in:
Ayke van Laethem
2022-12-18 17:27:23 +01:00
committed by Ayke
parent fb73074325
commit 17176a2cea
+3
View File
@@ -168,6 +168,9 @@ func (b gcBlock) markFree() {
if gcAsserts && b.state() != blockStateFree {
runtimePanic("gc: markFree() was not successful")
}
if gcAsserts {
*(*[wordsPerBlock]uintptr)(unsafe.Pointer(b.address())) = [wordsPerBlock]uintptr{}
}
}
// unmark changes the state of the block from mark to head. It must be marked