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
14
// the test only tests what we intend to test
15
// if dummy starts in the first 256 MB of memory.
16
// otherwise there might not be anything mapped
17
// at the address that might be accidentally
18
// dereferenced below.
19
if uintptr(unsafe.Pointer(&dummy)) > 256<<20 {
20
panic("dummy too far out")
23
// The problem here is that indexing into p[] with a large
24
// enough index jumps out of the unmapped section
25
// at the beginning of memory and into valid memory.
26
// Pointer offsets and array indices, if they are
27
// very large, need to dereference the base pointer
29
var p *[1<<30]byte = nil
30
println(p[256<<20]) // very likely to be inside dummy, but should crash