go/test/fixedbugs/issue26105.go
David Chase 1a27f048ad cmd/compile: make OpAddr depend on VarDef in storeOrder
Given a carefully constructed input, writebarrier would
split a block with the OpAddr in the first half and the
VarDef in the second half which ultimately leads to a
compiler crash because the scheduler is no longer able
to put them in the proper order.

To fix, recognize the implicit dependence of OpAddr on
the VarDef of the same symbol if any exists.

This fix was chosen over making OpAddr take a memory
operand to make the dependence explicit, because this
change is less invasive at this late part of the 1.11
release cycle.

Fixes #26105.

Change-Id: I9b65460673af3af41740ef877d2fca91acd336bc
Reviewed-on: https://go-review.googlesource.com/121436
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-06-29 15:20:52 +00:00

26 lines
543 B
Go

// compile
// Copyright 2018 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.
// Triggers a bug in writebarrier, which inserts one
// between (first block) OpAddr x and (second block) a VarDef x,
// which are then in the wrong order and unable to be
// properly scheduled.
package q
var S interface{}
func F(n int) {
fun := func(x int) int {
S = 1
return n
}
i := fun(([]int{})[n])
var fc [2]chan int
S = (([1][2]chan int{fc})[i][i])
}