diff --git a/src/cmd/5g/ggen.c b/src/cmd/5g/ggen.c index 832767e8620..de100620be6 100644 --- a/src/cmd/5g/ggen.c +++ b/src/cmd/5g/ggen.c @@ -29,10 +29,10 @@ markautoused(Prog* p) { for (; p; p = p->link) { if (p->from.name == D_AUTO && p->from.node) - p->from.node->used++; + p->from.node->used = 1; if (p->to.name == D_AUTO && p->to.node) - p->to.node->used++; + p->to.node->used = 1; } } diff --git a/src/cmd/6g/ggen.c b/src/cmd/6g/ggen.c index 2f68885bd36..02e67d6d41e 100644 --- a/src/cmd/6g/ggen.c +++ b/src/cmd/6g/ggen.c @@ -26,10 +26,10 @@ markautoused(Prog* p) { for (; p; p = p->link) { if (p->from.type == D_AUTO && p->from.node) - p->from.node->used++; + p->from.node->used = 1; if (p->to.type == D_AUTO && p->to.node) - p->to.node->used++; + p->to.node->used = 1; } } diff --git a/src/cmd/8g/ggen.c b/src/cmd/8g/ggen.c index c4f28236808..6a457019901 100644 --- a/src/cmd/8g/ggen.c +++ b/src/cmd/8g/ggen.c @@ -28,10 +28,10 @@ markautoused(Prog* p) { for (; p; p = p->link) { if (p->from.type == D_AUTO && p->from.node) - p->from.node->used++; + p->from.node->used = 1; if (p->to.type == D_AUTO && p->to.node) - p->to.node->used++; + p->to.node->used = 1; } } diff --git a/test/fixedbugs/bug423.go b/test/fixedbugs/bug423.go new file mode 100644 index 00000000000..4a04c77f622 --- /dev/null +++ b/test/fixedbugs/bug423.go @@ -0,0 +1,277 @@ +// run + +// Copyright 2012 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. + +// gc used to overflow a counter when a variable was +// mentioned 256 times, and generate stack corruption. + +package main + +func main() { + F(1) +} + +func F(arg int) { + var X int64 + _ = X // used once + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 // used 32 times + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 // used 64 times + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 // used 96 times + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 // used 128 times + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 // used 200 times + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 // used 256 times + if arg != 0 { + panic("argument was changed") + } +}