fleaz / CptHook

Receive webhooks from different applications and post them to IRC channels
MIT License
17 stars 8 forks source link

segmentation fault when starting after upgrading to v0.2.0 #35

Closed andir closed 5 years ago

andir commented 5 years ago

After upgrading to v0.2.0 and restarting the service fails with a segmentation fault. Even without adopting the configuration after upgrading the service should not crash this way...

From the looks of it the configuration crashes whenever an unkown module is being referenced. It logs the error but does not skip / exit / abort execution in a clean fashion:

https://github.com/fleaz/CptHook/blob/a04922ce3d3b8c2e0763c3445d7312a46d7a6f28/main.go#L87-L98

Dec 01 16:43:16 prometheus systemd[1]: Started cpthook.service.
Dec 01 16:43:16 prometheus sqzjnjc7sim4skp8jf9ccxi78p1njyhv-unit-script-cpthook-start[6511]: time="2018-12-01T16:43:16Z" level=info msg="Loglevel not defined in configuration. Defaulting to ERROR"
Dec 01 16:43:16 prometheus sqzjnjc7sim4skp8jf9ccxi78p1njyhv-unit-script-cpthook-start[6511]: time="2018-12-01T16:43:16Z" level=error msg="found configuration for unknown module: \"status\""
Dec 01 16:43:16 prometheus sqzjnjc7sim4skp8jf9ccxi78p1njyhv-unit-script-cpthook-start[6511]: panic: runtime error: invalid memory address or nil pointer dereference
Dec 01 16:43:16 prometheus sqzjnjc7sim4skp8jf9ccxi78p1njyhv-unit-script-cpthook-start[6511]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x809dbb]
Dec 01 16:43:16 prometheus sqzjnjc7sim4skp8jf9ccxi78p1njyhv-unit-script-cpthook-start[6511]: goroutine 1 [running]:
Dec 01 16:43:16 prometheus sqzjnjc7sim4skp8jf9ccxi78p1njyhv-unit-script-cpthook-start[6511]: main.main()
Dec 01 16:43:16 prometheus sqzjnjc7sim4skp8jf9ccxi78p1njyhv-unit-script-cpthook-start[6511]:         /build/go/src/github.com/fleaz/CptHook/main.go:94 +0x5ab

Configuration:

http:
  listen: '[::1]:8083'
irc:
  host: irc.hackint.eu
  nickname: nickname
  port: 6667
  ssl:
    enabled: true
modules:
  prometheus:
    channel: '#channel'
    enabled: true
  status:
    enabled: true
andir commented 5 years ago

The example configuration should also be changed. At least the status module must be removed.

https://github.com/fleaz/CptHook/blob/a04922ce3d3b8c2e0763c3445d7312a46d7a6f28/cpthook.yml.example#L22-L24

fleaz commented 5 years ago

This was already fixed in 'development' but I forgot to release a new version. I just releases v0.2.1 which contains a fix in the module loader and also a updated example config.

Thanks for reporting this :)