Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/json: possible bug when unmarshaling maps with a custom struct as their key #38771

Closed
skwair opened this issue Apr 30, 2020 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@skwair
Copy link

skwair commented Apr 30, 2020

What version of Go are you using (go version)?

$ go version
go version go1.14.2 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/antoine/.cache/go-build"
GOENV="/home/antoine/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/antoine/go"
GOPRIVATE=""
GOPROXY=""
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build123794036=/tmp/go-build -gno-record-gcc-switches"
GOROOT/bin/go version: go version go1.14.2 linux/amd64
GOROOT/bin/go tool compile -V: compile version go1.14.2
uname -sr: Linux 5.6.7-1-MANJARO
LSB Version:	n/a
Distributor ID:	ManjaroLinux
Description:	Manjaro Linux
Release:	20.0
Codename:	Lysia
/usr/lib/libc.so.6: GNU C Library (GNU libc) stable release version 2.31.

What did you do?

Here's a playground link describing the issue.

This issue seems to only occur when other.Name contains a special character (" or \ for example) after the size of the key.

What did you expect to see?

When unmarshaled, the keys are correct.

What did you see instead?

The keys are incorrect under certain circumstances.

@vaibhavsanap
Copy link

When I ran the code provided in playground link locally unmarshaling works as expected and key values printed by program are perfect

Go version which I am using for reference
go version go1.13.7 darwin/amd64
Output of code:
my-key-4
my-key-1
my-key-2
my-key-3

@networkimprov
Copy link

cc @mvdan

@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 1, 2020
@andybons andybons added this to the Unplanned milestone May 1, 2020
@mvdan
Copy link
Member

mvdan commented May 9, 2020

Duplicate of #38105, where the fix is already in master and it's being backported for 1.14.3.

@mvdan mvdan closed this as completed May 9, 2020
jspdown added a commit to jspdown/maesh that referenced this issue May 15, 2020
This commit also provides a workaround for golang/go#38771 on ServiceTrafficTargetKey. A test has been added to cover the changes made on the
TopologyBuilder.
jspdown added a commit to jspdown/maesh that referenced this issue May 18, 2020
This commit also provides a workaround for golang/go#38771 on ServiceTrafficTargetKey. A test has been added to cover the changes made on the
TopologyBuilder.
jspdown added a commit to jspdown/maesh that referenced this issue May 19, 2020
This commit also provides a workaround for golang/go#38771 on ServiceTrafficTargetKey. A test has been added to cover the changes made on the
TopologyBuilder.
@golang golang locked and limited conversation to collaborators May 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

6 participants