Skip to content

Commit f870ed5

Browse files
committed
runtime (gc): simplify extalloc and correct GC scan bounds
This change replaces the overcomplicated treap system used previously by the extalloc GC. The treap was difficult to understand, and added a lot of complexity. It has been replaced by a simple sorted list, which has roughly the same space overhead and time complexity. Additionally, a bug was found in the termination condition for the scanning code for both collectors. On the extalloc collector, this would cause a trailing pointer to be missed. On the conservative collector, this would cause the scanner to read out of bounds on architectures where pointer size was greater than alignment (AVR mostly).
1 parent 06df319 commit f870ed5

File tree

2 files changed

+190
-404
lines changed

2 files changed

+190
-404
lines changed

src/runtime/gc_conservative.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ func markRoots(start, end uintptr) {
410410
}
411411
}
412412

413-
for addr := start; addr < end; addr += unsafe.Alignof(addr) {
413+
for addr := start; addr+unsafe.Sizeof(unsafe.Pointer(nil)) <= end; addr += unsafe.Alignof(addr) {
414414
root := *(*uintptr)(unsafe.Pointer(addr))
415415
markRoot(addr, root)
416416
}

0 commit comments

Comments
 (0)