8000 [release-branch.go1.1] cmd/8g: Make clearfat non-interleaved with poi… · golang/go@fc9a18f · GitHub
[go: up one dir, main page]

Skip to content

Commit fc9a18f

Browse files
committed
[release-branch.go1.1] cmd/8g: Make clearfat non-interleaved with pointer calculations.
««« CL 11383043 / dc24634de6c5 cmd/8g: Make clearfat non-interleaved with pointer calculations. clearfat (used to zero initialize structures) will use AX for x86 block ops. If we write to AX while calculating the dest pointer, we will fill the structure with incorrect values. Since 64-bit arithmetic uses AX to synthesize a 64-bit register, getting an adress by indexing with 64-bit ops can clobber the register. Fixes #5820. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/11383043 »»» Update #5928 R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/11698043
1 parent f2fa995 commit fc9a18f

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/cmd/8g/ggen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ clearfat(Node *nl)
7878
c = w % 4; // bytes
7979
q = w / 4; // quads
8080

81-
gconreg(AMOVL, 0, D_AX);
8281
nodreg(&n1, types[tptr], D_DI);
8382
agen(nl, &n1);
83+
gconreg(AMOVL, 0, D_AX);
8484

8585
if(q >= 4) {
8686
gconreg(AMOVL, q, D_CX);

test/fixedbugs/issue5820.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// run
2+
3+
// Copyright 2013 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.
6+
7+
// issue 5820: register clobber when clearfat and 64 bit arithmetic is interleaved.
8+
9+
package main
10+
11+
func main() {
12+
array := make([][]int, 2)
13+
index := uint64(1)
14+
array[index] = nil
15+
if array[1] != nil {
16+
panic("array[1] != nil")
17+
}
18+
}

0 commit comments

Comments
 (0)
0