-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.Issue is not actionable because of missing required information, which needs to be provided.
Milestone
Description
What version of Go are you using (go version)?
go version go1.10 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/go"
GORACE=""
GOROOT="/opt/go"
GOTMPDIR=""
GOTOOLDIR="/opt/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-build061548367=/tmp/go-build"
What did you do?
Sadly I can't reproduce the issue, I can't even imagine how it could happen.
Very rarely our service crashes in strings.Replace, because (for some impossible reason) it receives the first (string) argument as 0x0 (nil), according to the backtrace:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x458675]
goroutine 25438489 [running]:
strings.Count(0x0, 0x7, 0xdd60a1, 0x1, 0xc456b46a68)
/opt/go/src/strings/strings_amd64.go:85 +0x96
strings.Replace(0x0, 0x7, 0xdd60a1, 0x1, 0xdd6242, 0x2, 0xffffffffffffffff, 0x20, 0x7)
/opt/go/src/strings/strings.go:847 +0x9b
.../logrusformat.(*MTLogrusFormat).Format(0xc42018c600, 0xc45479ca50, 0x7ff3e3065c34, 0xc456b46c02, 0x21, 0xc456b46cf0, 0x411e2d)
.../logrusformat/format.go:80 +0x29b
.../log/logrus-syslog-hook.(*SyslogHook).Fire(0xc42014cdc0, 0xc45479ca50, 0x2, 0xc420258238)
.../log/logrus-syslog-hook/syslog.go:80 +0x4dd
The sample code snippet is:
type F struct {}
func (f *F) a() {
x := "whatever"
y := strings.Replace(f.b(x), `"`, `\"`, -1)
}
func (f *F) b(i interface{}) string {
return fmt.Sprintf("%v", i)
}
So I'm calling some formatting method, which takes an interface and returns string.
By the way, I don't see this function call in the backtrace, it goes directly to Replace()->Count()
And then somehow Replace() gets a nil address as a first arg.
From what I can tell string can't be nil and this should not happen.
What did you expect to see?
no panic
What did you see instead?
panic
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.Issue is not actionable because of missing required information, which needs to be provided.