You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The TestReadFromSquid test case fails intermittently (especially on slower hosts, such as low-powered ARM systems) due to race condition in the goroutine which occasionally tries to read from an uninitialized ch.server (net.Conn).
=== RUN TestReadFromSquid
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x36ccb4]
goroutine 3 [running]:
github.com/boynux/squid-exporter/collector.TestReadFromSquid.func1()
/home/daniel/src/squid-exporter/collector/client_test.go:39 +0x44
created by github.com/boynux/squid-exporter/collector.TestReadFromSquid in goroutine 2
/home/daniel/src/squid-exporter/collector/client_test.go:37 +0x70
FAIL github.com/boynux/squid-exporter/collector 0.152s
The ch.server is initialized by the coc.readFromSquid call, so any delays between the goroutine starting and coc.readFromSquid being called will trigger the error.
To Reproduce
Add a small delay just before the coc.readFromSquid("test") line. Failure can be reliably reproduced with delays as small as 5 µs, demonstrating the timing-critical nature of it.
Expected behavior
Test should pass reliably on all systems.
OS (please complete the following information):
Irrelevant / any.
The text was updated successfully, but these errors were encountered:
Thank you for reporting this and for the analysis. I'll try to get to this as soon as I can. Meanwhile if you already have a fix in mind I'll be happy to review your PR.
Describe the bug
The TestReadFromSquid test case fails intermittently (especially on slower hosts, such as low-powered ARM systems) due to race condition in the goroutine which occasionally tries to read from an uninitialized
ch.server
(net.Conn).The
ch.server
is initialized by thecoc.readFromSquid
call, so any delays between the goroutine starting andcoc.readFromSquid
being called will trigger the error.To Reproduce
Add a small delay just before the
coc.readFromSquid("test")
line. Failure can be reliably reproduced with delays as small as 5 µs, demonstrating the timing-critical nature of it.Expected behavior
Test should pass reliably on all systems.
OS (please complete the following information):
Irrelevant / any.
The text was updated successfully, but these errors were encountered: