aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/export_test.go
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2026-02-27 14:57:48 -0500
committerGopher Robot <gobot@golang.org>2026-03-02 11:02:08 -0800
commitcc1241f353abbac2df2baf7abe09506be27782e8 (patch)
treeec62e3101a43b7ee63537eab3959174d9e32c3f9 /src/runtime/export_test.go
parenta5f474fc062a3b9140febc802b6cc38cbebdd973 (diff)
downloadgo-cc1241f353abbac2df2baf7abe09506be27782e8.tar.xz
runtime: fix printfloat, printcomplex buffer sizes
The buffers added in CL 716002 for printfloat64 and printcomplex128 are too small to fit the longest formatted values. For values that are too long, AppendFloat allocates, which may cause a crash for prints in places in the runtime where allocation is not allowed. Fixes #77854. Change-Id: I6a6a636cc2fc5cae9fda25f10b28fd641aa1ff28 Reviewed-on: https://go-review.googlesource.com/c/go/+/749947 Reviewed-by: Russ Cox <rsc@golang.org> Auto-Submit: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/runtime/export_test.go')
-rw-r--r--src/runtime/export_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go
index f71494174c..bc471e50a0 100644
--- a/src/runtime/export_test.go
+++ b/src/runtime/export_test.go
@@ -2084,6 +2084,24 @@ func DumpPrintQuoted(s string) string {
return string(buf)
}
+// DumpPrint returns the output of print(v).
+func DumpPrint[T any](v T) string {
+ gp := getg()
+ gp.writebuf = make([]byte, 0, 2048)
+ print(v)
+ buf := gp.writebuf
+ gp.writebuf = nil
+
+ return string(buf)
+}
+
+var (
+ Float64Bytes = float64Bytes
+ Float32Bytes = float32Bytes
+ Complex128Bytes = complex128Bytes
+ Complex64Bytes = complex64Bytes
+)
+
func GetScanAlloc() uintptr {
c := getMCache(getg().m)
return c.scanAlloc