tynany / frr_exporter

Prometheus exporter for Free Range Routing
MIT License
100 stars 34 forks source link

Fix nil pointer dereference right after startup #91

Closed taktv6 closed 2 years ago

taktv6 commented 2 years ago

Fixes this nil pointer issue:


ts=2022-10-20T08:19:05.606Z caller=frr_exporter.go:65 level=info msg="Starting frr_exporter" version="(version=, branch=, revision=)"
ts=2022-10-20T08:19:05.606Z caller=frr_exporter.go:66 level=info msg="Build context" build_context="(go=go1.19, user=, date=)"
ts=2022-10-20T08:19:05.607Z caller=frr_exporter.go:67 level=info msg="Listening on address" address=:9342
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x84499f]

goroutine 1 [running]:
github.com/prometheus/exporter-toolkit/web.ListenAndServe(0xdd1300?, 0xc000012d38, {0xa682a0, 0xc00003b0c0})
        /home/takt/go/pkg/mod/github.com/prometheus/exporter-toolkit@v0.8.0/web/tls_config.go:217 +0x21f
main.main()
        /home/takt/git/src/github.com/tynany/frr_exporter/frr_exporter.go:86 +0x756```
paketb0te commented 2 years ago

It appears that this regression was introduced by my changes in #90 :see_no_evil:

dswarbrick commented 2 years ago

It might be preferable to use the AddFlags function provided by exporter-toolkit. This will avoid the need for the proposed boolPtr function since it will actually expose the WebSystemdSocket flag option, rather than hardcoding it.

tynany commented 2 years ago

@taktv6, thanks for contributing! Can you please take a look at the comment from @dswarbrick?

taktv6 commented 2 years ago

I guess I've figured out how to hold this exporter-toolkit package. Should be better now.

dswarbrick commented 2 years ago

@tynany You might want to actually bump the version to v0.8.1, since v0.8.0 contains a small but significant bug. I haven't looked into whether that bug specifically would affect frr_exporter, but just to be on the safe side...