[go] runtime: add a test for issue 78081

1 view
Skip to first unread message

Keith Randall (Gerrit)

unread,
Mar 17, 2026, 6:46:13 PM (21 hours ago) Mar 17
to Michael Pratt, goph...@pubsubhelper.golang.org, Keith Randall, golang-co...@googlegroups.com
Attention needed from Michael Pratt

Keith Randall has uploaded the change for review

Keith Randall would like Michael Pratt to review this change.

Commit message

runtime: add a test for issue 78081

Contrive to have a bunch of stack shrinking going on during
memclrNoHeapPointersPreemptible calls.

Fails at tip with this patch:

--- a/src/runtime/malloc.go
+++ b/src/runtime/malloc.go
@@ -2184,6 +2184,7 @@ func reusableSize(size uintptr) bool {
// Use this with care; if the data being cleared is tagged to contain
// pointers, this allows the GC to run before it is all cleared.
func memclrNoHeapPointersChunked(size uintptr, x unsafe.Pointer) {
+ y := uintptr(x)
if getg().preempt {
// TODO: no need for this, except to test that
// the preemption point is ok for small zeroings.
@@ -2193,6 +2194,7 @@ func memclrNoHeapPointersChunked(size uintptr, x unsafe.Pointer) {
// may hold locks, e.g., profiling
goschedguarded()
}
+ x = unsafe.Pointer(y)
// got this from benchmarking. 128k is too small, 512k is too large.
const chunkBytes = 256 * 1024
for size > chunkBytes {

Update #78081
Change-Id: Id8f87a4b0d0970cbf971c90ab87703a9e5b3f121

Change diff

diff --git a/test/fixedbugs/issue78081.go b/test/fixedbugs/issue78081.go
new file mode 100644
index 0000000..cd8a97c
--- /dev/null
+++ b/test/fixedbugs/issue78081.go
@@ -0,0 +1,47 @@
+// run
+
+// Copyright 2026 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 "runtime"
+
+func main() {
+ runtime.GOMAXPROCS(2)
+ c := make(chan bool)
+ for i := 0; i < 16; i++ {
+ go func() {
+ var b []byte
+ for range 100000 {
+ f(&b)
+ }
+ c <- true
+ }()
+ }
+ for i := 0; i < 16; i++ {
+ <-c
+ }
+}
+
+var n int = 64 // constant, but the compiler doesn't know that
+
+//go:noinline
+func f(sink *[]byte) {
+ useStack(64) // Use 64KB of stack, so that shrinking might happen below.
+
+ x := make([]int, n, 128) // on stack
+ _ = append(x, make([]int, 128-n)...) // memclrNoHeapPointersPreemptible call is here
+
+ *sink = make([]byte, 1024) // make some garbage to cause GC
+}
+
+//go:noinline
+func useStack(depth int) {
+ var b [128]int
+ if depth == b[depth%len(b)] { // depth == 0
+ return
+ }
+ useStack(depth - 1)
+}

Change information

Files:
  • A test/fixedbugs/issue78081.go
Change size: S
Delta: 1 file changed, 47 insertions(+), 0 deletions(-)
Open in Gerrit

Related details

Attention is currently required from:
  • Michael Pratt
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Id8f87a4b0d0970cbf971c90ab87703a9e5b3f121
Gerrit-Change-Number: 755942
Gerrit-PatchSet: 1
Gerrit-Owner: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
Gerrit-Attention: Michael Pratt <mpr...@google.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Keith Randall (Gerrit)

unread,
Mar 17, 2026, 10:32:59 PM (17 hours ago) Mar 17
to Keith Randall, goph...@pubsubhelper.golang.org, Michael Pratt, golang-co...@googlegroups.com
Attention needed from Michael Pratt

Keith Randall voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Michael Pratt
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Id8f87a4b0d0970cbf971c90ab87703a9e5b3f121
Gerrit-Change-Number: 755942
Gerrit-PatchSet: 1
Gerrit-Owner: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
Gerrit-Attention: Michael Pratt <mpr...@google.com>
Gerrit-Comment-Date: Wed, 18 Mar 2026 02:32:55 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Michael Pratt (Gerrit)

unread,
10:48 AM (5 hours ago) 10:48 AM
to Keith Randall, goph...@pubsubhelper.golang.org, Michael Pratt, Go LUCI, golang-co...@googlegroups.com
Attention needed from Keith Randall

Michael Pratt voted Code-Review+2

Code-Review+2
Open in Gerrit

Related details

Attention is currently required from:
  • Keith Randall
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Id8f87a4b0d0970cbf971c90ab87703a9e5b3f121
Gerrit-Change-Number: 755942
Gerrit-PatchSet: 1
Gerrit-Owner: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
Gerrit-Attention: Keith Randall <k...@golang.org>
Gerrit-Comment-Date: Wed, 18 Mar 2026 14:48:34 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Keith Randall (Gerrit)

unread,
12:19 PM (3 hours ago) 12:19 PM
to Keith Randall, goph...@pubsubhelper.golang.org, Michael Pratt, Go LUCI, golang-co...@googlegroups.com
Attention needed from Keith Randall

Keith Randall voted Code-Review+1

Code-Review+1
Open in Gerrit

Related details

Attention is currently required from:
  • Keith Randall
Submit Requirements:
    • requirement satisfiedCode-Review
    • requirement satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Id8f87a4b0d0970cbf971c90ab87703a9e5b3f121
    Gerrit-Change-Number: 755942
    Gerrit-PatchSet: 1
    Gerrit-Owner: Keith Randall <k...@golang.org>
    Gerrit-Reviewer: Keith Randall <k...@golang.org>
    Gerrit-Reviewer: Keith Randall <k...@google.com>
    Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
    Gerrit-Attention: Keith Randall <k...@golang.org>
    Gerrit-Comment-Date: Wed, 18 Mar 2026 16:18:55 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    open
    diffy

    Keith Randall (Gerrit)

    unread,
    12:19 PM (3 hours ago) 12:19 PM
    to Keith Randall, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Keith Randall, Michael Pratt, Go LUCI, golang-co...@googlegroups.com

    Keith Randall submitted the change

    Change information

    Commit message:
    runtime: add a test for issue 78081

    Contrive to have a bunch of stack shrinking going on during
    memclrNoHeapPointersPreemptible calls.

    Fails at tip with this patch:

    --- a/src/runtime/malloc.go
    +++ b/src/runtime/malloc.go
    @@ -2184,6 +2184,7 @@ func reusableSize(size uintptr) bool {
    // Use this with care; if the data being cleared is tagged to contain
    // pointers, this allows the GC to run before it is all cleared.
    func memclrNoHeapPointersChunked(size uintptr, x unsafe.Pointer) {
    + y := uintptr(x)
    if getg().preempt {
    // TODO: no need for this, except to test that
    // the preemption point is ok for small zeroings.
    @@ -2193,6 +2194,7 @@ func memclrNoHeapPointersChunked(size uintptr, x unsafe.Pointer) {
    // may hold locks, e.g., profiling
    goschedguarded()
    }
    + x = unsafe.Pointer(y)
    // got this from benchmarking. 128k is too small, 512k is too large.
    const chunkBytes = 256 * 1024
    for size > chunkBytes {

    Update #78081
    Change-Id: Id8f87a4b0d0970cbf971c90ab87703a9e5b3f121
    Reviewed-by: Michael Pratt <mpr...@google.com>
    Reviewed-by: Keith Randall <k...@google.com>
    Files:
    • A test/fixedbugs/issue78081.go
    Change size: S
    Delta: 1 file changed, 47 insertions(+), 0 deletions(-)
    Branch: refs/heads/master
    Submit Requirements:
    • requirement satisfiedCode-Review: +1 by Keith Randall, +2 by Michael Pratt
    • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
    Open in Gerrit
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: merged
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Id8f87a4b0d0970cbf971c90ab87703a9e5b3f121
    Gerrit-Change-Number: 755942
    Gerrit-PatchSet: 2
    open
    diffy
    satisfied_requirement
    Reply all
    Reply to author
    Forward
    0 new messages