-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Open
Labels
FeatureRequestIssues asking for a new feature that does not need a proposal.Issues asking for a new feature that does not need a proposal.LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Feedback is required from experts, contributors, and/or the community before a change can be made.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone
Description
Go version
go version go1.25.5 darwin/arm64
Output of go env in your module/workspace:
AR='ar'
CC='cc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='c++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/user/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/user/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/w4/9h406zs53_d82t0jx555j4ww0000gn/T/go-build2324368129=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/tmp/testgo/go.mod'
GOMODCACHE='/Users/user/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/user/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.25.5/libexec'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/user/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.25.5/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.25.5'
GOWORK=''
PKG_CONFIG='pkg-config'What did you do?
GOMEMLIMIT=1.5GiB go run .What did you see happen?
GOMEMLIMIT=1.5GiB
fatal error: malformed GOMEMLIMIT; see `go doc runtime/debug.SetMemoryLimit`
runtime stack:
runtime.throw({0x10337f090?, 0xa?})
runtime/panic.go:1094 +0x34 fp=0x16d03eeb0 sp=0x16d03ee80 pc=0x102e367d4
runtime.readGOMEMLIMIT()
runtime/mgcpacer.go:1365 +0xb4 fp=0x16d03eee0 sp=0x16d03eeb0 pc=0x102de9c14
runtime.gcinit()
runtime/mgc.go:189 +0x38 fp=0x16d03ef10 sp=0x16d03eee0 pc=0x102de0318
runtime.schedinit()
runtime/proc.go:898 +0x1c0 fp=0x16d03ef80 sp=0x16d03ef10 pc=0x102e02b70
runtime.rt0_go()
runtime/asm_arm64.s:121 +0xcc fp=0x16d03efb0 sp=0x16d03ef80 pc=0x102e3c6dc
What did you expect to see?
According to the documentation GOMEMLIMIT is a numeric value with an optional unit suffix:
Lines 27 to 33 in d00e96d
| program. GOMEMLIMIT is a numeric value in bytes with an optional unit suffix. | |
| The supported suffixes include B, KiB, MiB, GiB, and TiB. These suffixes | |
| represent quantities of bytes as defined by the IEC 80000-13 standard. That is, | |
| they are based on powers of two: KiB means 2^10 bytes, MiB means 2^20 bytes, | |
| and so on. The default setting is [math.MaxInt64], which effectively disables the | |
| memory limit. [runtime/debug.SetMemoryLimit] allows changing this limit at run | |
| time. |
And numeric types include:
Lines 841 to 846 in d00e96d
| <h3 id="Numeric_types">Numeric types</h3> | |
| <p> | |
| An <i>integer</i>, <i>floating-point</i>, or <i>complex</i> type | |
| represents the set of integer, floating-point, or complex values, respectively. | |
| They are collectively called <i>numeric types</i>. |
However, GOMEMLIMIT only accepts integers:
Lines 402 to 415 in d00e96d
| // parseByteCount parses a string that represents a count of bytes. | |
| // | |
| // s must match the following regular expression: | |
| // | |
| // ^[0-9]+(([KMGT]i)?B)?$ | |
| // | |
| // In other words, an integer byte count with an optional unit | |
| // suffix. Acceptable suffixes include one of | |
| // - KiB, MiB, GiB, TiB which represent binary IEC/ISO 80000 units, or | |
| // - B, which just represents bytes. | |
| // | |
| // Returns an int64 because that's what its callers want and receive, | |
| // but the result is always non-negative. | |
| func parseByteCount(s string) (int64, bool) { |
Therefore, I would expect GOMEMLIMIT to either accept a float value or explicitly specify the types it accepts. For instance, systemd allows specifying memory constraints using a float value with a suffix.
Metadata
Metadata
Assignees
Labels
FeatureRequestIssues asking for a new feature that does not need a proposal.Issues asking for a new feature that does not need a proposal.LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Feedback is required from experts, contributors, and/or the community before a change can be made.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.