Please answer these questions before submitting your issue. Thanks!
go version)?go version go1.10.2 linux/amd64
N/A
go env)?GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/go"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
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-build689873858=/tmp/go-build -gno-record-gcc-switches"
We ran the executable in docker container (ubuntu) on digital ocean (centos). The code uses list.List to maintain some data.
list.List.PushBack should work
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x68f874]
goroutine 12 [running]:
container/list.(*List).insert(...)
/usr/local/go/src/container/list/list.go:97
container/list.(*List).insertValue(...)
/usr/local/go/src/container/list/list.go:105
container/list.(*List).PushBack(0xc4201775f0, 0x9cce60, 0xc4201ba000, 0xc42153f9e0)
/usr/local/go/src/container/list/list.go:140 +0x94
Can you provide a sample runnable program that shows this error?
@AlexRouSg this is where the panic happens: https://github.com/iotexproject/iotex-core/blob/fd5250a952d22c5c991f967f98670ef6647f62a0/trie/trie.go#L275. Hopefully this could be useful for you to diagnose.
Is it possible to be thread safe issue?
That is much too big to debug, if you cannot create a small program to reproduce this then chances are you're doing something wrong.
Have you tried running/building with -race enabled? https://blog.golang.org/race-detector
Yup, but unfortunately, we only encounter the issue sporadically in the distributed deployment, so that I couldn't give you a small program to reproduce it.
By -race, are you indicating it's the race condition on mutating the list?
The most obvious way to get your exact error message would be to call PushBack and Remove at the same time.
Proof of concept program below.
package main
import (
"container/list"
"fmt"
)
func main() {
l := list.List{}
ready := make(chan struct{})
go func() {
ready <- struct{}{}
for i := 0; i < (1 << 20); i++ {
l.PushBack(0)
}
}()
<-ready
for i := 0; i < (1 << 20); i++ {
l.Remove(l.Back())
}
fmt.Println(l.Len())
}
Thanks for the POC @AlexRouSg
Most helpful comment
That is much too big to debug, if you cannot create a small program to reproduce this then chances are you're doing something wrong.
Have you tried running/building with
-raceenabled? https://blog.golang.org/race-detector