runtime: don't mark the object right before a non-existing object

False positives (pointers that point to nowhere but happen to point into
the heap) would result in the block just before that pointer to be
marked. This is clearly not intended, so ignore such a pointer.
This commit is contained in:
Ayke van Laethem
2019-08-23 18:08:56 +02:00
committed by Ron Evans
parent 3bf2487dc5
commit 319d21e662
+6
View File
@@ -327,6 +327,12 @@ func markRoots(start, end uintptr) {
func markRoot(addr, root uintptr) {
if looksLikePointer(root) {
block := blockFromAddr(root)
if block.state() == blockStateFree {
// The to-be-marked object doesn't actually exist.
// This could either be a dangling pointer (oops!) but most likely
// just a false positive.
return
}
head := block.findHead()
if head.state() != blockStateMark {
if gcDebug {