Skip to content

cmd/compile: constant-string doubling plus []rune conversion can exhaust memory #78346

@jake-ciolek

Description

@jake-ciolek

Go version

go 1.26.1 + tip

Output of go env in your module/workspace:

GOARCH=arm64

What did you do?

package p

const (
	a = "x"
	b = a + a
	c = b + b
	d = c + c
	e = d + d
	f = e + e
	g = f + f
	h = g + g
	i = h + h
	j = i + i
	k = j + j
	l = k + k
	m = l + l
	n = m + m
	o = n + n
	p = o + o
	q = p + p
	r = q + q
	s = r + r
	t = s + s
	u = t + t
	v = u + u
	w = v + v
	x = w + w
	y = x + x
	z = y + y
	A = z + z
	B = A + A
	C = B + B
	D = C + C
	E = D + D
	F = E + E
	G = F + F
	H = G + G
	I = H + H
	J = I + I
	K = J + J
	L = K + K
	M = L + L
	N = M + M
	O = N + N
	P = O + O
	Q = P + P
	R = Q + Q
	S = R + R
	T = S + S
	U = T + T
	V = U + U
	W = V + V
	X = W + W
	Y = X + X
	Z = Y + Y
)

var _ = []rune(Z[:])

Ran go build on the above.

What did you see happen?

Extensive memory allocation and OOM.

What did you expect to see?

Low memory usage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.NeedsFixThe path to resolution is known, but the work has not been done.ToolSpeedcompiler/runtimeIssues related to the Go compiler and/or runtime.help wanted

    Type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions