How does the Go garbage collector know the beginning address of a slice's backing store, if the slice points to the middle of the original store?
Consider the following:
array := make([]int, 1000)
slice := array[999:1000]
array = nil
We are famously warned that the GC will hang on to the entire array although the ptr part of slice points towards the end of the original array.
But where is the original address of the array kept so the GC can clear it entirely? When the GC begins its mark phase and reaches slice, how does it mark the beginning of the array as "in use"?
Same question could be asked for other cases of the GC not collecting objects when the user only has a reference to part of them such as when the user only has references to a part of a struct or a string.
Edit: After some discussion I suspect that in all of these cases when the GC performs the mark phase for a user reference it performs a lookup in its internal allocation block mechanisms searching for the block within which the address of the user reference is contained and marks the entire block as "In Use"