-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
NeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone
Description
Go version
tip
Output of go env
in your module/workspace:
GO111MODULE=''
GOARCH='arm64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/khr/Library/Caches/go-build'
GOENV='/Users/khr/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/khr/gopath/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/khr/gopath'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/khr/sandbox/ro5'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/khr/sandbox/ro5/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='devel go1.24-fb5dcc1526 Mon Nov 4 12:50:55 2024 -0800'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/khr/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/khr/sandbox/ro5/src/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/z9/dty110711l9cr9w3ktv1_2380000gn/T/go-build1711499111=/tmp/go-build -gno-record-gcc-switches -fno-common'
What did you do?
package main
func nan() float64 {
var x, y float64
return x / y
}
func main() {
m := map[float64]int{}
// Make a small map with nan keys
for i := 0; i < 8; i++ {
m[nan()] = i
}
// Start iterating on it.
start := true
for k, v := range m {
if start {
// Add some more elements.
for i := 0; i < 10; i++ {
m[float64(i)] = i
}
// Now clear the map.
clear(m)
start = false
} else {
// This should never print anything.
println(k, v)
}
}
}
When run, this should never print anything. The map is cleared during the first iteration. No map elements should survive to cause a second iteration.
There is no bug now that we've switched by default to swiss maps. The old maps, which you can get with GOEXPERIMENT=noswissmap
, have this problem. This problem is present in 1.22.6 and 1.23.2. Presumably it has been there since clear
was introduced in 1.21.
Seems related to #59411. Somehow the fix for that issue doesn't help here.
What did you see happen?
NaN 3
NaN 4
NaN 5
NaN 6
NaN 7
NaN 0
NaN 1
What did you expect to see?
nothing printed
Metadata
Metadata
Assignees
Labels
NeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Type
Projects
Status
Done