Closed
Description
Go version
go version go1.24.2 linux/amd64
Output of go env
in your module/workspace:
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/user/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/user/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1565376817=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/home/user/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/user/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib64/go/1.24'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/user/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/lib64/go/1.24/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.2'
GOWORK=''
PKG_CONFIG='pkg-config'
What did you do?
Minimal example to reproduce:
package main
import (
"hash/maphash"
)
func main() {
maphash.Comparable(maphash.MakeSeed(), make(chan struct{}))
}
What did you see happen?
Run with go run -tags purego main.go
causes panic:
$ go run -tags purego main.go
panic: maphash: hash of unhashable type chan struct {}
goroutine 1 [running]:
hash/maphash.appendT(0xc0000a0e78, {0x497e40?, 0xc000096070?, 0x4112fe?})
/usr/lib64/go/1.24/src/hash/maphash/maphash_purego.go:176 +0x6f7
hash/maphash.writeComparable[...](0xc0000a0e78?, 0x1c0000a0f08)
/usr/lib64/go/1.24/src/hash/maphash/maphash_purego.go:111 +0x31
hash/maphash.comparableHash[...](0x0?, {0x552308?})
/usr/lib64/go/1.24/src/hash/maphash/maphash_purego.go:105 +0x58
hash/maphash.Comparable[...](...)
/usr/lib64/go/1.24/src/hash/maphash/maphash.go:289
main.main()
/home/user/src/1/main.go:8 +0x3d
exit status 2
The problem is that purego implementation of maphash doesn't handle reflect.Chan
kind of values: https://cs.opensource.google/go/go/+/refs/tags/go1.24.3:src/hash/maphash/maphash_purego.go;l=115-175
I can submit pull request which will make it handle reflect.Chan
as every other pointer types, hashing v.Pointer()
value.
What did you expect to see?
No panic like with regular go run main.go
command.
Activity
gabyhelp commentedon May 10, 2025
Related Issues
Related Code Changes
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
qiulaidongfeng commentedon May 10, 2025
Thanks for report.
You can send the fix, See https://go.dev/doc/contribute.
hash/maphash: hash channels in purego version too
gopherbot commentedon May 10, 2025
Change https://go.dev/cl/671655 mentions this issue:
hash/maphash: hash channels in purego version of maphash.Comparable
qiulaidongfeng commentedon May 11, 2025
@gopherbot please consider this for backport to 1.24. This issue causes when using pruego build tags, maphash.Comparable cannot handle channal type correctly. There is no solution.
gopherbot commentedon May 11, 2025
Backport issue(s) opened: #73669 (for 1.24).
Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.
hash/maphash: hash channels in purego version of maphash.Comparable
hash/maphash: hash channels in purego version of maphash.Comparable
gopherbot commentedon May 28, 2025
Change https://go.dev/cl/676817 mentions this issue:
[release-branch.go1.24] hash/maphash: hash channels in purego version of maphash.Comparable
[release-branch.go1.24] hash/maphash: hash channels in purego version…