]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: ensure that operand of ORETURN is not double-walked
authorDavid Chase <drchase@google.com>
Tue, 12 Jun 2018 18:10:33 +0000 (14:10 -0400)
committerDavid Chase <drchase@google.com>
Thu, 14 Jun 2018 20:08:10 +0000 (20:08 +0000)
commitc359d759a77fcec1457f3eb5c5d04fb74f47dad4
tree2cc63a289c30820c03fc9fcab9e8c11e5a641547
parent46076c37578fba9b49059584ef896099c9240fb2
cmd/compile: ensure that operand of ORETURN is not double-walked

Inlining of switch statements into a RETURNed expression
can sometimes lead to the switch being walked twice, which
results in a miscompiled switch statement. The bug depends
on:

1) multiple results
2) named results
3) a return statement whose expression includes a call to a
function containing a switch statement that is inlined.

It may also be significant that the default case of that
switch is a panic(), though that's not proven.

Rearranged the walk case for ORETURN so that double walks are
not possible.  Added a test, because this is so fiddly.
Added a check against double walks, verified that it fires
w/o other fix.

Fixes #25776.

Change-Id: I2d594351fa082632512ef989af67eb887059729b
Reviewed-on: https://go-review.googlesource.com/118318
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/gc/swt.go
src/cmd/compile/internal/gc/walk.go
test/fixedbugs/issue25776.go [new file with mode: 0644]