/usr/share/go-1.8/test/uintptrescapes.dir/main.go is in golang-1.8-src 1.8.3-2ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | // Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"fmt"
"os"
"sync"
"unsafe"
"./a"
)
func F1() int {
var buf [1024]int
a.F1(uintptr(unsafe.Pointer(&buf[0])))
return buf[0]
}
func F2() int {
var buf [1024]int
a.F2(uintptr(unsafe.Pointer(&buf[0])))
return buf[0]
}
var t = a.GetT()
func M1() int {
var buf [1024]int
t.M1(uintptr(unsafe.Pointer(&buf[0])))
return buf[0]
}
func M2() int {
var buf [1024]int
t.M2(uintptr(unsafe.Pointer(&buf[0])))
return buf[0]
}
func main() {
// Use different goroutines to force stack growth.
var wg sync.WaitGroup
wg.Add(4)
c := make(chan bool, 4)
go func() {
defer wg.Done()
b := F1()
if b != 42 {
fmt.Printf("F1: got %d, expected 42\n", b)
c <- false
}
}()
go func() {
defer wg.Done()
b := F2()
if b != 42 {
fmt.Printf("F2: got %d, expected 42\n", b)
c <- false
}
}()
go func() {
defer wg.Done()
b := M1()
if b != 42 {
fmt.Printf("M1: got %d, expected 42\n", b)
c <- false
}
}()
go func() {
defer wg.Done()
b := M2()
if b != 42 {
fmt.Printf("M2: got %d, expected 42\n", b)
c <- false
}
}()
wg.Wait()
select {
case <-c:
os.Exit(1)
default:
}
}
|