Commit 8b1b81f4 authored by Russ Cox's avatar Russ Cox

cmd/compile: fix crash with -race on large expr containing string->[]byte conversion

The assumption is that there are no nested function calls in complex expressions.
For the most part that assumption is true. It wasn't for these calls inserted during walk.
Fix that.

I looked through all the calls to mkcall in walk and these were the only cases
that emitted calls, that could be part of larger expressions (like not delete),
and that were not already handled.

Fixes #12225.

Change-Id: Iad380683fe2e054d480e7ae4e8faf1078cdd744c
Reviewed-on: https://go-review.googlesource.com/17034Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent 45c3cf68
......@@ -1092,7 +1092,10 @@ func orderexpr(np **Node, order *Order, lhs *Node) {
OMAKESLICE,
ONEW,
OREAL,
ORECOVER:
ORECOVER,
OSTRARRAYBYTE,
OSTRARRAYBYTETMP,
OSTRARRAYRUNE:
ordercall(n, order)
if lhs == nil || lhs.Op != ONAME || instrumenting {
n = ordercopyexpr(n, n.Type, order, 0)
......
// Copyright 2015 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 race_test
// golang.org/issue/12225
// The test is that this compiles at all.
func issue12225() {
println(*(*int)(unsafe.Pointer(&convert("")[0])))
println(*(*int)(unsafe.Pointer(&[]byte("")[0])))
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment