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/gob: decoding of pointers with two levels of indirection is broken #8872

gopherbot opened this issue Oct 6, 2014 · 3 comments


Copy link

@gopherbot gopherbot commented Oct 6, 2014


go version 1.3.3 (happens at, too)

What steps reproduce the problem?

1. Create two structs A and B. 
2. Let B contain an exported int I, and A an exported pointer to a pointer to B named P.
3. Create an instance of B, set I, create an instance of A and let X point to a pointer
to the instance of B.
4. Encode with Gob.
5. Decode with Gob.

=> The value of I is incorrect.


What happened?

Gob does not properly decode pointers with two levels of indirection. It seems that the
decoder adds another level of indirection (one to many). Example where you can see this

What should have happened instead?

Pointers should be decoded correctly.

Please provide any additional information below.

There were issues with pointers in the past like : 

decIndirect in the decoder is called twice with indir = 2 in the decoding process for A.
The second or the first call should use 1. I did not look into it deep enough to provide
a fix / suggestion.
Copy link

@ianlancetaylor ianlancetaylor commented Oct 6, 2014

Comment 1:

Labels changed: added repo-main, release-go1.5.

Status changed to Accepted.

@bradfitz bradfitz modified the milestone: Go1.5 Dec 16, 2014
@bradfitz bradfitz removed the release-go1.5 label Dec 16, 2014
@rsc rsc removed accepted labels Apr 14, 2015
Copy link

@osocurioso osocurioso commented Jun 15, 2015

Seems not to be reproducible on go1.4.2 (current playground).

Copy link

@rsc rsc commented Jul 14, 2015

Working for me on Go 1.4 and at tip.

@rsc rsc closed this Jul 14, 2015
@golang golang locked and limited conversation to collaborators Jul 13, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.