panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x45c3d2]
message=‘’ •••
panic(0xc03040, 0x116d2f0)
golang/go/src/runtime/panic.go:531 +0x1cf fp=0xc47d406d90 sp=0xc47d406cf8
runtime.panicmem()
golang/go/src/runtime/panic.go:63 +0x5e fp=0xc47d406db0 sp=0xc47d406d90
runtime.sigpanic()
golang/go/src/runtime/signal_unix.go:290 +0x29f fp=0xc47d406e00 sp=0xc47d406db0
runtime.memmove(0xc44f8e4500, 0x0, 0x18)
golang/go/src/runtime/memmove_amd64.s:178 +0x682 fp=0xc47d406e08 sp=0xc47d406e00 our/source/code.glob..func5.1(0x0, 0x3, 0x3, 0xc43104d380, 0xc436f05900, 0x73, 0xc47bd2e8a0, 0x24, 0xc437f1d616, 0x6, ...)
/our/source/code.go:123 +0xa2 fp=0xc47d406f58 sp=0xc47d406e08
runtime.goexit()
golang/go/src/runtime/asm_amd64.s:2197 +0x1 fp=0xc47d406f60 sp=0xc47d406f58
created by our/source/code.glob..func5
/our/source/code.go:132 +0x150
Here's the stripped-down source code fragment (our/source/code.go with relevant line numbers added)
var f = func(a A, b, c string, src []int64, d string, e, f string, g []byte) chan error {
ec := make(chan error, somepkg.Count())
go func(a A) {
dest := make([]int64, len(src))
123: copy(dest, src)
defer close(ec)
...
defer something()
...
132:}(a)
return ec
}
At first, this looks like an OOM as it seems to be triggered by a copy to a freshly allocated array (dest := make([]int64, len(src)) + copy(dest, src)). But at closer inspection memmove(0xc44f8e4500, 0x0, 0x18) seems to indicate that the source is 0 (the second parameter if we trust memmove_amd64.s). In that case, how could the length (0x18) have been determined in the first place?
Put differently, how can
ptr of a slice (as in
https://blog.golang.org/go-slices-usage-and-internals) be a null pointer when the slice has a length? Does this indicate a missed check of malloc (or however the equivalent is called in the go runtime env)? Or am I misunderstanding the trace?