diff options
| author | Michael Pratt <mpratt@google.com> | 2026-03-20 17:49:14 -0400 |
|---|---|---|
| committer | Keith Randall <khr@golang.org> | 2026-03-20 18:35:15 -0700 |
| commit | 16018b05ae226e7a99f166bded7f939c5b0c4a98 (patch) | |
| tree | fb85edaa72238b92cfc750c569d42aa37cc90ee0 /src/runtime/malloc.go | |
| parent | 2de90fd48f2e4e38c2805e81b37d4116004752e2 (diff) | |
| download | go-16018b05ae226e7a99f166bded7f939c5b0c4a98.tar.xz | |
Revert "runtime: fix memclrNoHeapPointersPreemptible"
This reverts CL 756122.
Reason: Adding preemptible memclrNoHeapPointers exposes existing unsafe
use of notInHeapSlice, causing crashes. Revert the memclr stack until
the underlying issue is fixed.
For #78254.
Change-Id: I8a234d1a6dddf70d9aa5ecda1ac8bb25deb08248
Reviewed-on: https://go-review.googlesource.com/c/go/+/757342
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Diffstat (limited to 'src/runtime/malloc.go')
| -rw-r--r-- | src/runtime/malloc.go | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index 44b4b3bc57..2144ea602a 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -2184,27 +2184,22 @@ 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) { - if getg().preempt { - // TODO: no need for this, except to test that - // the preemption point is ok for small zeroings. - // (The pre-CL-756122 allowed preemption in this case, - // which is probably why we noticed 78081 at all.) - // Remove once we think 78081 is fixed. - // may hold locks, e.g., profiling - goschedguarded() - } + v := uintptr(x) // got this from benchmarking. 128k is too small, 512k is too large. const chunkBytes = 256 * 1024 - for size > chunkBytes { - memclrNoHeapPointers(x, chunkBytes) - x = add(x, chunkBytes) - size -= chunkBytes + vsize := v + size + for voff := v; voff < vsize; voff = voff + chunkBytes { if getg().preempt { // may hold locks, e.g., profiling goschedguarded() } + // clear min(avail, lump) bytes + n := vsize - voff + if n > chunkBytes { + n = chunkBytes + } + memclrNoHeapPointers(unsafe.Pointer(voff), n) } - memclrNoHeapPointers(x, size) } // memclrNoHeapPointersPreemptible is the compiler-callable entry point |
