3 // Copyright 2018 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 // Make sure return values aren't scanned until they
8 // are initialized, when calling functions and methods
24 // Allocate large enough to use largeAlloc.
25 b := make([]byte, 1<<16-1)
26 sink = b // force heap allocation
27 // Any space between the object and the end of page is invalid to point to.
28 badPtr = uintptr(unsafe.Pointer(&b[len(b)-1])) + 1
31 func f(d func() *byte) *byte {
32 // Initialize callee args section with a bad pointer.
35 // Then call a function which returns a pointer.
36 // That return slot starts out holding a bad pointer.
47 func (t *T) Foo() *byte {
54 d := reflect.MakeFunc(reflect.TypeOf(func() *byte { return nil }),
55 func(args []reflect.Value) []reflect.Value {
57 return []reflect.Value{reflect.ValueOf((*byte)(nil))}
58 }).Interface().(func() *byte)
62 e := reflect.ValueOf(&T{}).Method(0).Interface().(func() *byte)