evalphobia / logrus_sentry

sentry hook for logrus
MIT License
194 stars 78 forks source link

Enabling stacktrace + logrus.FieldLogger + goroutine cause panic. #42

Closed cheshir closed 7 years ago

cheshir commented 7 years ago

I'm trying to log errors with stacktraces in goroutines but every time caught a panic.

Here is a snippet.

Here is a panic message:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x12c7306]

goroutine 11 [running]:
sentry_err/vendor/github.com/getsentry/raven-go.(*Stacktrace).Culprit(0x0, 0x1533860, 0x0)
    /Users/cheshir/projects/go/src/sentry_err/vendor/github.com/getsentry/raven-go/stacktrace.go:27 +0x26
sentry_err/vendor/github.com/getsentry/raven-go.(*Packet).Init(0xc4204b6480, 0x138a89c, 0x1, 0x0, 0xc42045b618)

What I'm doing wrong?

evalphobia commented 7 years ago

@cheshir Would you check error from NewAsyncSentryHook() ?

I got sentry's DSN error on the snippets.

    hook, err := logrus_sentry.NewAsyncSentryHook(dsn, []log.Level{
        log.PanicLevel,
        log.FatalLevel,
        log.ErrorLevel,
        log.WarnLevel,
    })
    if err != nil {
        panic(err) // => panic: raven: dsn missing public key and/or password
    }
cheshir commented 7 years ago

@evalphobia Did you set up it properly?

cheshir commented 7 years ago

@evalphobia I have a problem only when hook.StacktraceConfiguration.Enable = true. If I comment this line all works well but without stacktrace.

evalphobia commented 7 years ago

@cheshir I found some error when stack frame is shallow and skipped, then nil value is added to the packet. It causes panic on sentry client.

I fixed it on v0.2.14 tag, would you confirm is it fixed on your case? https://github.com/evalphobia/logrus_sentry/releases/tag/v0.2.14

Thank you for your report!

cheshir commented 7 years ago

@evalphobia Thank you for fast response. Yes, all works well.