mirror of
https://github.com/golang/go.git
synced 2025-11-01 09:10:57 +00:00
[dev.garbage] all: merge dev.cc (493ad916c3b1) into dev.garbage
TBR=austin CC=golang-codereviews https://golang.org/cl/179290043
This commit is contained in:
commit
b8540fc288
207 changed files with 4734 additions and 11182 deletions
|
|
@ -546,6 +546,8 @@ func GC() {
|
|||
|
||||
// linker-provided
|
||||
var noptrdata struct{}
|
||||
var enoptrdata struct{}
|
||||
var noptrbss struct{}
|
||||
var enoptrbss struct{}
|
||||
|
||||
// SetFinalizer sets the finalizer associated with x to f.
|
||||
|
|
@ -622,8 +624,13 @@ func SetFinalizer(obj interface{}, finalizer interface{}) {
|
|||
// func main() {
|
||||
// runtime.SetFinalizer(Foo, nil)
|
||||
// }
|
||||
// The segments are, in order: text, rodata, noptrdata, data, bss, noptrbss.
|
||||
if uintptr(unsafe.Pointer(&noptrdata)) <= uintptr(e.data) && uintptr(e.data) < uintptr(unsafe.Pointer(&enoptrbss)) {
|
||||
// The relevant segments are: noptrdata, data, bss, noptrbss.
|
||||
// We cannot assume they are in any order or even contiguous,
|
||||
// due to external linking.
|
||||
if uintptr(unsafe.Pointer(&noptrdata)) <= uintptr(e.data) && uintptr(e.data) < uintptr(unsafe.Pointer(&enoptrdata)) ||
|
||||
uintptr(unsafe.Pointer(&data)) <= uintptr(e.data) && uintptr(e.data) < uintptr(unsafe.Pointer(&edata)) ||
|
||||
uintptr(unsafe.Pointer(&bss)) <= uintptr(e.data) && uintptr(e.data) < uintptr(unsafe.Pointer(&ebss)) ||
|
||||
uintptr(unsafe.Pointer(&noptrbss)) <= uintptr(e.data) && uintptr(e.data) < uintptr(unsafe.Pointer(&enoptrbss)) {
|
||||
return
|
||||
}
|
||||
gothrow("runtime.SetFinalizer: pointer not in allocated block")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue