Closed
Description
What version of Go are you using (go version
)?
$ go version go version go1.15.5 darwin/amd64
Does this issue reproduce with the latest release?
Yes, but 1.14.2 is work.
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE="on" GOARCH="amd64" GOBIN="" GOCACHE="/Users/mac/Library/Caches/go-build" GOENV="/Users/mac/Library/Application Support/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/mac/workspace/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/mac/workspace/go" GOPRIVATE="" GOPROXY="https://goproxy.cn,direct" GOROOT="/Users/mac/program/go" GOSUMDB="" GOTMPDIR="" GOTOOLDIR="/Users/mac/program/go/pkg/tool/darwin_amd64" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/Users/mac/program/go/src/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 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/y7/wj_j6jds1j7bz0bvp_bz1kf00000gn/T/go-build694457940=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
a := A{}
m := map[string]interface{}{}
d, _ := json.Marshal(a)
json.Unmarshal(d, &m)
Compile docker for linux on macos and run it on k8s
What did you expect to see?
Parse data to map
What did you see instead?
unexpected fault address 0x26000000c6
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x1 addr=0x26000000c6 pc=0x52445d]
goroutine 93 [running]:
runtime.throw(0x1178d74, 0x5)
/Users/mac/program/go/src/runtime/panic.go:1116 +0x72 fp=0xc00064d768 sp=0xc00064d738 pc=0x437752
runtime.sigpanic()
/Users/mac/program/go/src/runtime/signal_unix.go:749 +0x405 fp=0xc00064d798 sp=0xc00064d768 pc=0x44dae5
encoding/json.(*encodeState).string(0xc00055e300, 0x26000000c6, 0x102000000c1, 0x2600000001)
/Users/mac/program/go/src/encoding/json/encode.go:1004 +0x5d fp=0xc00064d7f8 sp=0xc00064d798 pc=0x52445d
encoding/json.stringEncoder(0xc00055e300, 0xfc68c0, 0xc000512d00, 0x98, 0x100)
/Users/mac/program/go/src/encoding/json/encode.go:645 +0x1d6 fp=0xc00064d878 sp=0xc00064d7f8 pc=0x521896
encoding/json.structEncoder.encode(0xc0006dd800, 0x22, 0x43, 0xc000597590, 0xc00055e300, 0x1166c40, 0xc000512b38, 0x99, 0x100)
/Users/mac/program/go/src/encoding/json/encode.go:759 +0x2ab fp=0xc00064d910 sp=0xc00064d878 pc=0x52220b
encoding/json.structEncoder.encode-fm(0xc00055e300, 0x1166c40, 0xc000512b38, 0x99, 0x100)
/Users/mac/program/go/src/encoding/json/encode.go:730 +0x7f fp=0xc00064d968 sp=0xc00064d910 pc=0x52eb9f
encoding/json.structEncoder.encode(0xc0006a8600, 0x3b, 0x43, 0xc00059a150, 0xc00055e300, 0x11733c0, 0xc0005126a0, 0x99, 0x100)
/Users/mac/program/go/src/encoding/json/encode.go:759 +0x2ab fp=0xc00064da00 sp=0xc00064d968 pc=0x52220b
encoding/json.structEncoder.encode-fm(0xc00055e300, 0x11733c0, 0xc0005126a0, 0x99, 0x100)
/Users/mac/program/go/src/encoding/json/encode.go:730 +0x7f fp=0xc00064da58 sp=0xc00064da00 pc=0x52eb9f
encoding/json.structEncoder.encode(0xc0006db200, 0x23, 0x43, 0xc00059a1b0, 0xc00055e300, 0x1167360, 0xc0005122c8, 0x99, 0x100)
/Users/mac/program/go/src/encoding/json/encode.go:759 +0x2ab fp=0xc00064daf0 sp=0xc00064da58 pc=0x52220b
encoding/json.structEncoder.encode-fm(0xc00055e300, 0x1167360, 0xc0005122c8, 0x99, 0x100)
/Users/mac/program/go/src/encoding/json/encode.go:730 +0x7f fp=0xc00064db48 sp=0xc00064daf0 pc=0x52eb9f
encoding/json.structEncoder.encode(0xc00084a000, 0x20, 0x21, 0xc00059b2c0, 0xc00055e300, 0x11643a0, 0xc000511a60, 0x99, 0x100)
/Users/mac/program/go/src/encoding/json/encode.go:759 +0x2ab fp=0xc00064dbe0 sp=0xc00064db48 pc=0x52220b
encoding/json.structEncoder.encode-fm(0xc00055e300, 0x11643a0, 0xc000511a60, 0x99, 0x100)
/Users/mac/program/go/src/encoding/json/encode.go:730 +0x7f fp=0xc00064dc38 sp=0xc00064dbe0 pc=0x52eb9f
encoding/json.structEncoder.encode(0xc0006ce400, 0xd, 0x10, 0xc00059b320, 0xc00055e300, 0x11367c0, 0xc00050e000, 0x99, 0x1130100)
/Users/mac/program/go/src/encoding/json/encode.go:759 +0x2ab fp=0xc00064dcd0 sp=0xc00064dc38 pc=0x52220b
encoding/json.structEncoder.encode-fm(0xc00055e300, 0x11367c0, 0xc00050e000, 0x99, 0x1c20100)
/Users/mac/program/go/src/encoding/json/encode.go:730 +0x7f fp=0xc00064dd28 sp=0xc00064dcd0 pc=0x52eb9f
encoding/json.(*encodeState).reflectValue(0xc00055e300, 0x11367c0, 0xc00050e000, 0x99, 0xc000640100)
/Users/mac/program/go/src/encoding/json/encode.go:358 +0x82 fp=0xc00064dd60 sp=0xc00064dd28 pc=0x51f902
encoding/json.(*encodeState).marshal(0xc00055e300, 0x11367c0, 0xc00050e000, 0xc000640100, 0x0, 0x0)
/Users/mac/program/go/src/encoding/json/encode.go:330 +0xf4 fp=0xc00064ddc0 sp=0xc00064dd60 pc=0x51f4f4
encoding/json.Marshal(0x11367c0, 0xc00050e000, 0xc000125020, 0x203000, 0x203000, 0x203000, 0x0)
/Users/mac/program/go/src/encoding/json/encode.go:161 +0x52 fp=0xc00064de38 sp=0xc00064ddc0 pc=0x51e972
Activity
davecheney commentedon Nov 24, 2020
Thank you for raising this issue. Your sample code looks incomplete as the stack trace you included mentioned goroutine 93 whereas the code fragment you provided did not use goroutines.
Can you please
nzlov commentedon Nov 24, 2020
@davecheney
No data race.
Demo needs to wait.
mvdan commentedon Nov 24, 2020
Line 1004 in question is
if b := s[i]; b < utf8.RuneSelf {
, so this is certainly not a bug in json.Without a reproducer or more details, there's not much we can do here.
xtutu commentedon Feb 8, 2021
hi, @nzlov I met the same issuse.
Do you solve it?
davecheney commentedon Feb 8, 2021
@xtutu please log a new issue and be sure to complete the entire template. You must provide a way for someone else to reproduce the problem you are seeing.
xtutu commentedon Feb 8, 2021
@davecheney , i found what happy in my code . it solved.
valueList is data race.
davecheney commentedon Feb 8, 2021
Thank you. I am closing and resolving this issue.