mirror of
https://github.com/golang/go
synced 2024-11-22 16:34:47 -07:00
1ed30ca537
Pointer comparison is lowered to the following on RISCV64 (EqPtr x y) => (SEQZ (SUB <x.Type> x y)) The difference of two pointers (the SUB) should not be pointer type. Otherwise it can cause the GC to find a bad pointer. Should fix #51101. Change-Id: I7e73c2155c36ff403c032981a9aa9cccbfdf0f64 Reviewed-on: https://go-review.googlesource.com/c/go/+/385655 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
37 lines
523 B
Go
37 lines
523 B
Go
// run
|
|
|
|
// Copyright 2022 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 51101: on RISCV64, difference of two pointers
|
|
// was marked as pointer and crashes GC.
|
|
|
|
package main
|
|
|
|
var a, b int
|
|
|
|
func main() {
|
|
F(&b, &a)
|
|
}
|
|
|
|
//go:noinline
|
|
func F(a, b *int) bool {
|
|
x := a == b
|
|
G(x)
|
|
y := a != b
|
|
return y
|
|
}
|
|
|
|
//go:noinline
|
|
func G(bool) {
|
|
grow([1000]int{20})
|
|
}
|
|
|
|
func grow(x [1000]int) {
|
|
if x[0] != 0 {
|
|
x[0]--
|
|
grow(x)
|
|
}
|
|
}
|