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.
Этот коммит содержится в:
Ayke van Laethem 2019-08-23 18:08:56 +02:00 коммит произвёл Ron Evans
родитель 3bf2487dc5
коммит 319d21e662

Просмотреть файл

@ -327,6 +327,12 @@ func markRoots(start, end uintptr) {
func markRoot(addr, root uintptr) { func markRoot(addr, root uintptr) {
if looksLikePointer(root) { if looksLikePointer(root) {
block := blockFromAddr(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() head := block.findHead()
if head.state() != blockStateMark { if head.state() != blockStateMark {
if gcDebug { if gcDebug {