diff options
author | Austin Clements <austin@google.com> | 2015-08-24 13:35:49 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2015-08-25 14:37:08 +0000 |
commit | 05a3b1fce56a95e40512bae9f62656098f198834 (patch) | |
tree | 0a5bb8ab10f462a7d7fe885f9b577252db651e2d /src/runtime/gc_test.go | |
parent | 686d44d9e0c4e43716f8dd51ffaf81b8754f3620 (diff) | |
download | go-05a3b1fce56a95e40512bae9f62656098f198834.tar.gz go-05a3b1fce56a95e40512bae9f62656098f198834.zip |
cmd/compile: fix uninitialized memory in compare of interface value
A comparison of the form l == r where l is an interface and r is
concrete performs a type assertion on l to convert it to r's type.
However, the compiler fails to zero the temporary where the result of
the type assertion is written, so if the type is a pointer type and a
stack scan occurs while in the type assertion, it may see an invalid
pointer on the stack.
Fix this by zeroing the temporary. This is equivalent to the fix for
type switches from c4092ac.
Fixes #12253.
Change-Id: Iaf205d456b856c056b317b4e888ce892f0c555b9
Reviewed-on: https://go-review.googlesource.com/13872
Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/runtime/gc_test.go')
-rw-r--r-- | src/runtime/gc_test.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/runtime/gc_test.go b/src/runtime/gc_test.go index 636e5248c8..6c9b314c65 100644 --- a/src/runtime/gc_test.go +++ b/src/runtime/gc_test.go @@ -469,3 +469,20 @@ func testAssertVar(x interface{}) error { } return nil } + +func TestAssertE2T2Liveness(t *testing.T) { + *runtime.TestingAssertE2T2GC = true + defer func() { + *runtime.TestingAssertE2T2GC = false + }() + + poisonStack() + testIfaceEqual(io.EOF) +} + +func testIfaceEqual(x interface{}) { + if x == "abc" { + // Prevent inlining + panic("") + } +} |