[Bug] panic: invalid argument to Intn
JoseAmador95 opened this issue · 0 comments
Hi! I'm getting an error when running the simulator. It is related to the mrand.Intn
function from math/rand
in line 220 of simulator.go. According to the Go docs, the function panics when n < 0, but I couldn't get the instruction time.Duration(mrand.Intn(int(s.activationTime)))
to output a negative value in order to replicate the issue, but hardcoding the whole instruction to a constant does make the simulator work as expected. The details of the error are shown below.
chirpstack-simulator/internal/simulator/simulator.go
Lines 216 to 223 in 63fdb49
Console Output
panic: invalid argument to Intn
goroutine 57 [running]:
math/rand.(*Rand).Intn(0x1890160, 0xf8475800, 0x1a8e410)
/usr/local/go/src/math/rand/rand.go:169 +0x7c
math/rand.Intn(...)
/usr/local/go/src/math/rand/rand.go:329
github.com/brocaar/chirpstack-simulator/internal/simulator.(*simulation).runSimulation(0x1a46000, 0x0, 0x0)
/home/pi/chirpstack-simulator/internal/simulator/simulator.go:220 +0x5a8
github.com/brocaar/chirpstack-simulator/internal/simulator.(*simulation).start(0x1a46000)
/home/pi/chirpstack-simulator/internal/simulator/simulator.go:106 +0xb8
created by github.com/brocaar/chirpstack-simulator/internal/simulator.Start
/home/pi/chirpstack-simulator/internal/simulator/simulator.go:69 +0x3a4