slok / gospinner

Make beautiful and fast spinners in Go
MIT License
17 stars 3 forks source link

panic: index out of range #1

Open leonj1 opened 7 years ago

leonj1 commented 7 years ago

panic seen during setMessage() https://github.com/leonj1/brute-force-crack-pdf-password/blob/8ecdfe9c34949a7c8fee844f8b93653ed6560783/main.go#L63

⣷ Working: 00dbhpanic: runtime error: index out of range

goroutine 20 [running]:
github.com/slok/gospinner.(*Spinner).Render(0x10777650, 0x10750040, 0x1071f7cc)
        /home/pirate/go/src/github.com/slok/gospinner/spinner.go:167 +0x2b0
github.com/slok/gospinner.(*Spinner).StartWithSpeed.func1(0x10777650, 0x4c4b400, 0x0)
        /home/pirate/go/src/github.com/slok/gospinner/spinner.go:153 +0xc8
created by github.com/slok/gospinner.(*Spinner).StartWithSpeed
        /home/pirate/go/src/github.com/slok/gospinner/spinner.go:155 +0xc8

panic points to: https://github.com/slok/gospinner/blob/master/spinner.go#L167

I'm not sure how to debug this or find the root cause, but this is a long running program I wrote (link included). I doubt my app is the cause, but thought I'd make you aware.

BTW, my app is iterating over a 5TB text file, and at time of panic it was at line 50672.

slok commented 7 years ago

Hi @leonj1

Sorry about that :(

I will try to reproduce the panic and fix it when I have some spare time.

Many thanks! :metal:

leonj1 commented 7 years ago

I have forked and added a unit test showing where it fails. This is an isolation test case to make it easier to find the root cause. https://github.com/leonj1/gospinner/blob/master/doit.sh This shell script first creates a seed input file with random words, used for the test.

leonj1 commented 7 years ago

Ran the 'doit.sh' for 2 hours and did not fail =\ It timed out (which I hard coded). Now increasing the timeout to 5 hours. Informing you so you don't have to do this yourself. This is a trivial test, only because I doubt its my app itself. If 5 hrs does not reproduce the index out of range error, then I will be forced to look at my code =)

leonj1 commented 7 years ago

Unexpected. Test passed. Now I'm going to have to run a test with bits from my app.

$ ./doit.sh
✔ Loading
✔ Current word ZZZZZ
PASS
ok      github.com/leonj1/gospinner 8394.017s
slok commented 7 years ago

That is strange!

Keep me updated and thank you for all your effort.