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
Milestone

Comments

@elwinar
Copy link
Contributor

@elwinar 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

This comment has been minimized.

Copy link
Contributor Author

@elwinar elwinar commented May 1, 2019

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented May 1, 2019

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

@katiehockman katiehockman added this to the Go1.14 milestone May 1, 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 added 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
@gopherbot gopherbot closed this in b6ec56b Sep 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.