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: Inconsistent results with pointers and duplicated keys #31776

Closed
elwinar opened this issue May 1, 2019 · 2 comments
Closed

encoding/json: Inconsistent results with pointers and duplicated keys #31776

elwinar opened this issue May 1, 2019 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@elwinar
Copy link
Contributor

elwinar commented May 1, 2019

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

$ go version
go version go1.12.4 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
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/elwinar/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/elwinar/.go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build786320136=/tmp/go-build -gno-record-gcc-switches"

What did you do?

https://play.golang.org/p/8ELiG37J-JI

What did you expect to see?

{<nil>} <nil>
{<nil>} <nil>

What did you see instead?

{0x40c1e8} <nil>
{<nil>} <nil>

As mentioned is dvyukov/go-fuzz-corpus#3, although the result itself is valid stricto sensu, it is inconsistent. We would expect either the first or the last indirection to be always nil, while it seems to depends on the previous value of the field.

@elwinar
Copy link
Contributor Author

elwinar commented May 1, 2019

CC @mvdan @josharian .

@gopherbot
Copy link

Change https://golang.org/cl/174699 mentions this issue: encoding/json: check the type of a value when indirecting it

@katiehockman katiehockman added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label May 1, 2019
@katiehockman katiehockman added this to the Go1.14 milestone May 1, 2019
@andybons andybons added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. labels May 14, 2019
elwinar pushed a commit to elwinar/go that referenced this issue Sep 9, 2019
The indirect method checked the type of the child when indirecting a
pointer. If the current value is a pointer and we are decoding null, we
can skip this entirely and return early, avoiding the whole descent.

Fixes golang#31776

Change-Id: Ib8b2a2357572c41f56fceac59b5a858980f3f65e
elwinar pushed a commit to elwinar/go that referenced this issue Sep 10, 2019
The indirect method checked the type of the child when indirecting a
pointer. If the current value is a pointer and we are decoding null, we
can skip this entirely and return early, avoiding the whole descent.

Fixes golang#31776

Change-Id: Ib8b2a2357572c41f56fceac59b5a858980f3f65e
@golang golang locked and limited conversation to collaborators Sep 9, 2020
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

4 participants