1
0
mirror of https://github.com/golang/go synced 2024-11-25 06:17:58 -07:00
go/test/fixedbugs/issue69434.go
Cuong Manh Le e470a00cdf test: fix test issue 69434 for riscv64
CL 615915 simplified test for issue 69434, using gcflags maymorestack to
force stack moving, making program failed with invalid stack pointer.

However, it seems that this maymorestack is broken on riscv64. At least
gotip-linux-riscv64 is currently broken.

This CL fixes this problem by using the initial approach, growing stack
size big enough to force stack moving.

Updates #69434
Fixes #69714

Cq-Include-Trybots: luci.golang.try:gotip-linux-riscv64
Change-Id: I95255fba884a200f75bcda34d58e9717e4a952ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/616698
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
2024-10-01 18:13:35 +00:00

62 lines
772 B
Go

// run
// Copyright 2024 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 main
import (
"iter"
)
func All() iter.Seq[int] {
return func(yield func(int) bool) {
for i := 0; i < 10; i++ {
growStack(512)
if !yield(i) {
return
}
}
}
}
type S struct {
round int
}
func NewS(round int) *S {
s := &S{round: round}
return s
}
func (s *S) check(round int) {
if s.round != round {
panic("bad round")
}
}
func f() {
rounds := 0
s := NewS(rounds)
s.check(rounds)
for range All() {
s.check(rounds)
rounds++
s = NewS(rounds)
s.check(rounds)
}
}
func growStack(i int) {
if i == 0 {
return
}
growStack(i - 1)
}
func main() {
f()
}