1
// $G $D/$F.go && $L $F.$A &&
2
// ((! sh -c ./$A.out) >/dev/null 2>&1 || echo BUG: should fail)
4
// Copyright 2009 The Go Authors. All rights reserved.
5
// Use of this source code is governed by a BSD-style
6
// license that can be found in the LICENSE file.
12
var dummy [512<<20]byte // give us a big address space
19
// the test only tests what we intend to test
20
// if dummy starts in the first 256 MB of memory.
21
// otherwise there might not be anything mapped
22
// at the address that might be accidentally
23
// dereferenced below.
24
if uintptr(unsafe.Pointer(&dummy)) > 256<<20 {
25
panic("dummy too far out")
28
// The problem here is that indexing into t with a large
29
// enough index can jump out of the unmapped section
30
// at the beginning of memory and into valid memory.
31
// We require the address calculation to check.
33
println(&t.i) // should crash