vbauerster / mpb

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

fatal error: unknown caller pc #138

Closed shenwei356 closed 7 months ago

shenwei356 commented 7 months ago

mpb version 8.7.0

In my function xxx, I created a progress bar with 128K jobs. Each job updated durations, while some (tens) of jobs sent duration of time.Duration(0) (my bad, I'll try with 1 ms). And the function xxx was run multiple times. While after the 6th run (3 hours later), some runtime happened (see 2nd code block), which looks related to `mpb.

The app was tested with other small datasets, and everything was fine.

func xxx() {
        // process bar
    var pbs *mpb.Progress
    var bar *mpb.Bar
    var chDuration chan time.Duration
    var doneDuration chan int
    if opt.Verbose {
        pbs = mpb.New(mpb.WithWidth(40), mpb.WithOutput(os.Stderr))
        bar = pbs.AddBar(int64(len(files)),
            mpb.PrependDecorators(
                decor.Name("processed files: ", decor.WC{W: len("processed files: "), C: decor.DindentRight}),
                decor.Name("", decor.WCSyncSpaceR),
                decor.CountersNoUnit("%d / %d", decor.WCSyncWidth),
            ),
            mpb.AppendDecorators(
                decor.Name("ETA: ", decor.WC{W: len("ETA: ")}),
                decor.EwmaETA(decor.ET_STYLE_GO, 10),
                decor.OnComplete(decor.Name(""), ". done"),
            ),
        )

        chDuration = make(chan time.Duration, opt.NumCPUs)
        doneDuration = make(chan int)
        go func() {
            for t := range chDuration {
                bar.EwmaIncrBy(1, t)
            }
            doneDuration <- 1
        }()
    }

      // jobs
}
runtime: g 51299948: unexpected return pc for fmt.newPrinter called from 0xcddc0000
stack: frame={sp:0xc00aca0e60, fp:0xc00aca0e67} stack=[0xc00aca0000,0xc00aca1000)
0x000000c00aca0d60:  0x0000000000418268 <runtime.heapBitsSetType+0x0000000000000288>  0x000000c00aca0e00
0x000000c00aca0d70:  0x000000000048477d <sync.(*Pool).pinSlow+0x00000000000000fd>  0x0000000000000000
0x000000c00aca0d80:  0x00000000007e7c17 <github.com/vbauerster/mpb/v8.(*bState).draw+0x0000000000000097>  0x000000c00006a500
0x000000c00aca0d90:  0x000000c18074edc8  0x00000000008920e0
0x000000c00aca0da0:  0x000000000088a5c0  0x000000c00a90df30
0x000000c00aca0db0:  0x000000c18074edc8  0x010000c00006c4c0
0x000000c00aca0dc0:  0x0000000000000000  0x00000000002bfafa
0x000000c00aca0dd0:  0x000000000000000d  0x0000000000000000
0x000000c00aca0de0:  0x000000000044c3c5 <runtime.readyWithTime+0x0000000000000085>  0x0000000000484900 <sync.(*Pool).pinSlow.func1+0x0000000000000000>
0x000000c00aca0df0:  0x0000000000d1b840  0x000000c00aca0de8
0x000000c00aca0e00:  0x000000c00aca0e18  0x0000000000484665 <sync.(*Pool).pin+0x0000000000000045>
0x000000c00aca0e10:  0x0000000000cddc00  0x000000c00aca0e50
0x000000c00aca0e20:  0x00000000004843bc <sync.(*Pool).Get+0x000000000000001c>  0x0000000000cddc00
0x000000c00aca0e30:  0x0000000000cf42a0  0x000000c46b335920
0x000000c00aca0e40:  0x0000000000cf42a0  0x000000c50d913358
0x000000c00aca0e50:  0x000000c00aca0e78  0x00000000004ea7be <fmt.newPrinter+0x000000000000001e>
0x000000c00aca0e60: <0x0000000000cddc00  0x000000c18074eee0
0x000000c00aca0e70:  0x0000000000408e00 <runtime.chansend+0x0000000000000560>  0x000000c18074eed0
0x000000c00aca0e80:  0x00000000004ead70 <fmt.Sprintf+0x0000000000000030>  0x0000000000485665 <sync.(*WaitGroup).Add+0x0000000000000085>
0x000000c00aca0e90:  0x000000c3e8df1b00  0x000000c18074eef0
0x000000c00aca0ea0:  0x000000c0cbfe9401  0x000000018074eee0
0x000000c00aca0eb0:  0x000000c18074ef08  0x00000000007ef217 <github.com/vbauerster/mpb/v8.pState.push+0x0000000000000097>
0x000000c00aca0ec0:  0x000000c50d913350  0x00000000000000ad
0x000000c00aca0ed0:  0x000000c18074efa8  0x00000000008046db <github.com/shenwei356/LexicMap/lexicmap/cmd.buildAnIndex.func7+0x00000000000000db>
0x000000c00aca0ee0:  0x00000000008e76e0  0x000000000000000c
0x000000c00aca0ef0:  0x000000c18074ef88  0x0000000000000002
0x000000c00aca0f00:  0x0000000000000002  0x000000c18074efd0
0x000000c00aca0f10:  0x00000000007eef5a <github.com/vbauerster/mpb/v8.(*pState).flush.func5+0x000000000000005a>  0x00000000009ad288
0x000000c00aca0f20:  0x000000000000001f  0x000000000000001b
0x000000c00aca0f30:  0x000000c00010ed90  0x000000c2d6e2ace0
0x000000c00aca0f40:  0x000000c1362ebb60  0x000000c3be88a8e0
0x000000c00aca0f50:  0x000000c0145949c0  0x0000000008f0d180
0x000000c00aca0f60:  0x0000000000000028
fatal error: unknown caller pc

runtime stack:
runtime.throw({0x8e9a81, 0x0})
        /usr/local/go/src/runtime/panic.go:1077 +0x5c fp=0xc00049baa8 sp=0xc00049ba78 pc=0x438e1c
runtime.(*unwinder).next(0x4d00000000004846, 0xaca1000000000c0, 0x0, 0xc00aca00000000, 0x0, 0x0, 0x0, 0xffff0000de2c0000, 0x100032a4d, 0xc00aca100000, 0x0, 0x2c0000000000424
9, 0x0, 0x88000000c00049bc

I just updated it to v8.7.2 and run again, I'll report tomorrow.

shenwei356 commented 7 months ago

I re-ran with mpb v8.7.2 and also updated the duration bar.EwmaIncrBy(1, t) with 1 ms instead of 0. No error was reported.