jpbruinsslot/slack-term

Crash on first time.

stephanemartin opened this issue · 5 comments

Version: master branch
Installation method: go get -u github.com/erroneousboat/slack-term
~/go/src/github.com/erroneousboat/slack-term$ go install .
~/go/bin$ ./slack-term -token xxxxxxxxxxxxx

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

goroutine 1 [running]:
github.com/erroneousboat/slack-term/service.NewSlackService(0xc0000d2dc0, 0x27, 0xc0000d2dc0, 0x0)
/home/smartin/go/src/github.com/erroneousboat/slack-term/service/slack.go:71 +0x2b6
github.com/erroneousboat/slack-term/context.CreateAppContext(0xc00002a210, 0x27, 0x7fff9b8cf768, 0x4c, 0x0, 0x98e37d, 0x6, 0xc0000fc5a0, 0x116, 0xc0000a0160, ...)
/home/smartin/go/src/github.com/erroneousboat/slack-term/context/context.go:81 +0xd7
main.main()
/home/smartin/go/src/github.com/erroneousboat/slack-term/main.go:99 +0x1c2

Affected by same. Will attempt to install via binary next.

Same result with binary v0.5.0: https://github.com/erroneousboat/slack-term/releases/tag/v0.5.0

$> slack-term-darwin-amd64 -config ~/.config/slack-term.config
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x1440ba6]

goroutine 1 [running]:
github.com/erroneousboat/slack-term/service.NewSlackService(0xc0000acdc0, 0x29, 0xc0000acdc0, 0x0)
        /home/jp/Projects/slack-term/service/slack.go:71 +0x2b6
github.com/erroneousboat/slack-term/context.CreateAppContext(0x7ffeefbfeb62, 0x29, 0x0, 0x0, 0x0, 0x157420f, 0x6, 0xc00002c900, 0x116, 0xc00001e1c0, ...)
        /home/jp/Projects/slack-term/context/context.go:81 +0xd7
main.main()
        /home/jp/Projects/slack-term/main.go:99 +0x1c2

Same result on v0.4.1 but different stack trace:

$> slack-term-darwin-amd64 -config ~/.config/slack-term.config
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x13a26d1]

goroutine 1 [running]:
github.com/erroneousboat/slack-term/service.NewSlackService(0xc420250000, 0x29, 0xc420250000, 0x0)
        /home/jp/go/src/github.com/erroneousboat/slack-term/service/slack.go:66 +0x2f1
github.com/erroneousboat/slack-term/context.CreateAppContext(0x7ffeefbfeb62, 0x29, 0x0, 0x0, 0x0, 0x14b1fc7, 0x6, 0xc42024e120, 0x116, 0x0, ...)
        /home/jp/go/src/github.com/erroneousboat/slack-term/context/context.go:77 +0xd3
main.main()
        /home/jp/go/src/github.com/erroneousboat/slack-term/main.go:102 +0x1b4

FWIW, my slack-term.config only contains the key slack_token with the token I obtained through the GitHub Pages method from the wiki.

Confirmed the same result as the above reports - both pulling the binaries and building from scratch off of the current head #c19c20a

The nil pointer dereference is happening on slack.go line 66:

 // Get name of current user, and set presence to active
currentUser, err := svc.Client.GetUserInfo(svc.CurrentUserID)
if err != nil {
    svc.CurrentUsername = "slack-term"
}

svc.CurrentUsername = currentUser.Name // <--- crashes HERE due to null currentUser

Changing to this gets around the crash:

 // Get name of current user, and set presence to active
currentUser, err := svc.Client.GetUserInfo(svc.CurrentUserID)
if err != nil {
    svc.CurrentUsername = "slack-term"
} else {
    svc.CurrentUsername = currentUser.Name
}

Then the program exits with the error message:

2021/02/02 13:29:56 missing_scope

It looks like something isn't set up correctly with the token / access, causing the user info to not be available and the missing_scope error.

Same issue here on FreeBSD (13.0-several), running version 0.5.0_1 from ports.

*panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x7070d0]
goroutine 125 [running]:14]
github.com/0xAX/notificator.Notificator.Push(0x0, 0x0, 0x0, 0x0, 0x83f97e, 0xa, 0xc000304d50, 0x21, 0x0, 0x0, ...)
  ● eli/wrkdirs/usr/ports/net-im/slack-term/work/github.com/erroneousboat/slack-term@v0.5.0/vendor/github.com/0xAX/notificator/notification.go:42 +0x70
github.com/erroneousboat/slack-term/handlers.createNotifyMessage.func1(0xc0004be000, 0xc000128780)
  ○ gre/wrkdirs/usr/ports/net-im/slack-term/work/github.com/erroneousboat/slack-term@v0.5.0/handlers/event.go:806 +0x245
created by github.com/erroneousboat/slack-term/handlers.createNotifyMessage
  ○ jac/wrkdirs/usr/ports/net-im/slack-term/work/github.com/erroneousboat/slack-term@v0.5.0/handlers/event.go:784 +0x49

When started I can scroll through the channels just fine, typing not sure atm, but after a minute or so it will crash.