diff options
author | R?my Oudompheng <oudomphe@phare.normalesup.org> | 2013-03-25 22:09:55 +0100 |
---|---|---|
committer | R?my Oudompheng <oudomphe@phare.normalesup.org> | 2013-03-25 22:09:55 +0100 |
commit | 9928dd60b133a798f8975591ac5f077f65b43284 (patch) | |
tree | a29aad88aff45d13840a2f76c5e02e1aa4c5b612 | |
parent | af5080721f9bc16d05fbbd2fc43302024c023fdf (diff) | |
download | go-9928dd60b133a798f8975591ac5f077f65b43284.tar.gz |
cmd/5l, cmd/6l, cmd/8l: fix segfault on reading LOCALS for a duplicate definition.
Fixes issue 5105.
R=golang-dev, dave, daniel.morsing, rsc
CC=golang-dev
https://codereview.appspot.com/7965043
-rw-r--r-- | src/cmd/5l/obj.c | 4 | ||||
-rw-r--r-- | src/cmd/6l/obj.c | 4 | ||||
-rw-r--r-- | src/cmd/8l/obj.c | 4 | ||||
-rw-r--r-- | test/fixedbugs/issue5105.dir/a.go | 7 | ||||
-rw-r--r-- | test/fixedbugs/issue5105.dir/b.go | 15 | ||||
-rw-r--r-- | test/fixedbugs/issue5105.go | 10 |
6 files changed, 44 insertions, 0 deletions
diff --git a/src/cmd/5l/obj.c b/src/cmd/5l/obj.c index d38da204a..f5128c678 100644 --- a/src/cmd/5l/obj.c +++ b/src/cmd/5l/obj.c @@ -608,11 +608,15 @@ loop: break; case ALOCALS: + if(skip) + goto casedef; cursym->locals = p->to.offset; pc++; break; case ATYPE: + if(skip) + goto casedef; pc++; goto loop; diff --git a/src/cmd/6l/obj.c b/src/cmd/6l/obj.c index 3775df9de..ab8b22e23 100644 --- a/src/cmd/6l/obj.c +++ b/src/cmd/6l/obj.c @@ -597,11 +597,15 @@ loop: goto loop; case ALOCALS: + if(skip) + goto casdef; cursym->locals = p->to.offset; pc++; goto loop; case ATYPE: + if(skip) + goto casdef; pc++; goto loop; diff --git a/src/cmd/8l/obj.c b/src/cmd/8l/obj.c index 306e288a3..fda96d09c 100644 --- a/src/cmd/8l/obj.c +++ b/src/cmd/8l/obj.c @@ -607,11 +607,15 @@ loop: goto loop; case ALOCALS: + if(skip) + goto casdef; cursym->locals = p->to.offset; pc++; goto loop; case ATYPE: + if(skip) + goto casdef; pc++; goto loop; diff --git a/test/fixedbugs/issue5105.dir/a.go b/test/fixedbugs/issue5105.dir/a.go new file mode 100644 index 000000000..f20abb98b --- /dev/null +++ b/test/fixedbugs/issue5105.dir/a.go @@ -0,0 +1,7 @@ +// Copyright 2013 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 a + +var A = [2]string{"hello", "world"} diff --git a/test/fixedbugs/issue5105.dir/b.go b/test/fixedbugs/issue5105.dir/b.go new file mode 100644 index 000000000..b12e739e3 --- /dev/null +++ b/test/fixedbugs/issue5105.dir/b.go @@ -0,0 +1,15 @@ +// Copyright 2013 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 "./a" + +var B = [2]string{"world", "hello"} + +func main() { + if a.A[0] != B[1] { + panic("bad hello") + } +} diff --git a/test/fixedbugs/issue5105.go b/test/fixedbugs/issue5105.go new file mode 100644 index 000000000..e3e5e5caa --- /dev/null +++ b/test/fixedbugs/issue5105.go @@ -0,0 +1,10 @@ +// rundir + +// Copyright 2013 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. + +// Issue 5105: linker segfaults on duplicate definition +// of a type..hash.* function. + +package ignored |