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: gob is appending extra data to the output of UnmarshalBinary method. #51645

Closed
slayerjain opened this issue Mar 13, 2022 · 1 comment

Comments

@slayerjain
Copy link

slayerjain commented Mar 13, 2022

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

go version go1.17.8 darwin/arm64

Does this issue reproduce with the latest release?

yes

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

go env Output
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/shubhamjain/Library/Caches/go-build"
GOENV="/Users/shubhamjain/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/shubhamjain/go/pkg/mod"
GONOPROXY="github.com/keploy/go-agent"
GONOSUMDB="github.com/keploy/go-agent"
GOOS="darwin"
GOPATH="/Users/shubhamjain/go"
GOPRIVATE="github.com/keploy/go-agent"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/homebrew/Cellar/go/1.17.8/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.17.8/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.17.8"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/shubhamjain/projects/misc/cadre/keploy/Isolate/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/0r/802yxytj4x91n8gq_6czv12r0000gn/T/go-build2638397173=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I was trying to encode and decode HTTP responses. to deal with the body I created a custom ReadCloser with its own UnmarshalBinary and MarshalBinary methods. The gob output was inconsistent with the output of the UnmarshalBinary

I also created a sample repo to demonstrate the same - https://github.com/slayerjain/gob-decode-issue

What did you expect to see?

I expected the gob output to match the output of the UnmarshalBinary method that I defined

What did you see instead?

Some extra gibberish is added along with the expected data. Likely from the TLS object of the http.response

@seankhliao
Copy link
Member

UnmarshalBinary must be able to decode the form generated by MarshalBinary. UnmarshalBinary must copy the data if it wishes to retain the data after returning.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@golang golang locked and limited conversation to collaborators Mar 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants