vbauerster / mpb

multi progress bar for Go cli applications
The Unlicense
2.29k stars 123 forks source link

runtime error: makeslice: len out of range #74

Closed nitishgargiitd closed 4 years ago

nitishgargiitd commented 4 years ago

We launched a developer tool using this lib last week, 2 users reported the error below, but it works for most of us. We are distributing a compiled binary through homebrew, so we can be sure everyone is running the same go binary.

One of them is using iTerm2 3.3.6, I tested against the same version, but works fine for me

Our implementation looks very similar to one in https://github.com/vbauerster/mpb/blob/master/_examples/complex/main.go

runtime error: makeslice: len out of range
decor.Statistics{ID:0, AvailableWidth:144, Total:215, Current:-21, Refill:0, Completed:false}
goroutine 59 [running]:
runtime/debug.Stack(0xc0006897b0, 0x1, 0x1)
/home/kochiku/.cache/pants/bin/go/linux/x86_64/1.14.3/go/go/src/runtime/debug/stack.go:24 +0x9d
github.com/vbauerster/mpb.makePanicExtender(0x16fb340, 0x18d7870, 0x18d7870)
/home/kochiku/data/.pants.d/binary/golang/src/github.com/vbauerster/mpb/bar.go:468 +0x8a
github.com/vbauerster/mpb.(*Bar).render.func1.1(0xc0002130e0, 0x0, 0x90, 0xd7, 0xffffffffffffffeb, 0x0, 0x0, 0xc00010a800)
/home/kochiku/data/.pants.d/binary/golang/src/github.com/vbauerster/mpb/bar.go:308 +0x86
panic(0x16fb340, 0x18d7870)
/home/kochiku/.cache/pants/bin/go/linux/x86_64/1.14.3/go/go/src/runtime/panic.go:969 +0x166
github.com/vbauerster/mpb.(*barFiller).Fill(0xc000237c80, 0x18e5b00, 0xc0004fbef0, 0x40, 0x0, 0x6e, 0xd7, 0xffffffffffffffeb, 0x0, 0x0)
/home/kochiku/data/.pants.d/binary/golang/src/github.com/vbauerster/mpb/bar_filler_bar.go:117 +0x228
github.com/vbauerster/mpb.BarFillerOnComplete.func1.1(0x18e5b00, 0xc0004fbef0, 0x40, 0x0, 0x6e, 0xd7, 0xffffffffffffffeb, 0x0, 0x0)
/home/kochiku/data/.pants.d/binary/golang/src/github.com/vbauerster/mpb/bar_option.go:85 +0xb3
github.com/vbauerster/mpb.BarFillerFunc.Fill(0xc0004fbe90, 0x18e5b00, 0xc0004fbef0, 0x40, 0x0, 0x6e, 0xd7, 0xffffffffffffffeb, 0x0, 0x0)
/home/kochiku/data/.pants.d/binary/golang/src/github.com/vbauerster/mpb/bar_filler.go:29 +0x68
github.com/vbauerster/mpb.(*bState).draw(0xc0002130e0, 0x0, 0x6e, 0xd7, 0xffffffffffffffeb, 0x0, 0x0, 0x0, 0x0)
/home/kochiku/data/.pants.d/binary/golang/src/github.com/vbauerster/mpb/bar.go:410 +0x6cc
github.com/vbauerster/mpb.(*Bar).render.func1(0xc0002130e0)
/home/kochiku/data/.pants.d/binary/golang/src/github.com/vbauerster/mpb/bar.go:318 +0x1be
github.com/vbauerster/mpb.(*Bar).serve(0xc00010a800, 0x18f7d60, 0xc0000b9ec0, 0xc0002130e0)
/home/kochiku/data/.pants.d/binary/golang/src/github.com/vbauerster/mpb/bar.go:288 +0x83
created by github.com/vbauerster/mpb.newBar
/home/kochiku/data/.pants.d/binary/golang/src/github.com/vbauerster/mpb/bar.go:96 +0x371
vbauerster commented 4 years ago

What version of mpb do you use?

nitishgargiitd commented 4 years ago

a55da8df10b6d8d8172eea63c25e65bf975806d6 - v5.2.2

we also tried to upgrade the version of mpb to the latest, i.e. 03ab54c25b65ba834c03a30bf355110245ebb0b9 - July 17th commit and no success

vbauerster commented 4 years ago

You somehow getting Current:-21, this is a root cause of panic.

nitishgargiitd commented 4 years ago

makes sense, but how? and why it's happening for only few people, and it's happening consistently on their machine.

vbauerster commented 4 years ago

Do you use SetCurrent method? If yes double check its usage. I believe that panicking in this case is correct behavior, because otherwise you could end up displaying wrong data silently and never detect the bug.

nitishgargiitd commented 4 years ago

Yes, we are using SetCurrent, what should I check about it, anything specific you have in mind that is causing this issue.

vbauerster commented 4 years ago

Most probably you're setting negative current value at some point. You should probably check what causes it to be negative.

nitishgargiitd commented 4 years ago

got it, let me check.

nitishgargiitd commented 4 years ago

Ahh I think I got it. we are doing something like this

bar.SetCurrent(time.Now().Unix() - someUTCTimestampFromDB)

So on those few machines, machine times must be messed up and hence causing this to be negative.

Bug on our side, thanks for your help, you are awesome and really fast!