Open buaazp opened 7 years ago
Hi @chzyer , a strange panic:
colWidth is zero cause this panic, code is here: https://github.com/chzyer/readline/blob/master/complete.go#L205
panic: runtime error: integer divide by zero goroutine 23 [running]: gopkg.in/readline%2ev1.(*opCompleter).CompleteRefresh(0xc420131500) /Users/zippo/develop/go/src/gopkg.in/readline.v1/complete.go:195 +0x9c4 gopkg.in/readline%2ev1.(*wrapWriter).Write(0xc4208c4a40, 0xc4207f8ec0, 0x15, 0x40, 0x1, 0x1, 0x1010e48) /Users/zippo/develop/go/src/gopkg.in/readline.v1/operation.go:58 +0x16a fmt.Fprintf(0x148cac0, 0xc4208c4a40, 0x13413bd, 0x7, 0xc42004b5b0, 0x1, 0x1, 0x100e3ff, 0x12cdde0, 0xc4208ee0e8) /usr/local/opt/go/libexec/src/fmt/print.go:182 +0xa9 main.ttyPrintf(0x13413bd, 0x7, 0xc42004b5b0, 0x1, 0x1) /Users/zippo/develop/go/src/mosaic/tools/cli/utils.go:162 +0xf4 main.(*clusterCache).getAllECGroupID(0xc420086370, 0xc4208c4a20, 0xe, 0xc4208c4a20, 0xc4208c4a20, 0xc4207f9778) /Users/zippo/develop/go/src/mosaic/tools/cli/cmdCluster.go:288 +0x296 main.(*clusterCache).(main.getAllECGroupID)-fm(0xc4208c4a20, 0xe, 0xe, 0xe, 0xc4208c4a20) /Users/zippo/develop/go/src/mosaic/tools/cli/cmdList.go:915 +0x3e gopkg.in/readline%2ev1.(*PrefixCompleter).GetDynamicNames(0xc4200f8480, 0xc4207f9740, 0xe, 0xe, 0xc4200f8480, 0x1, 0xc42004b980) /Users/zippo/develop/go/src/gopkg.in/readline.v1/complete_helper.go:68 +0xb4 gopkg.in/readline%2ev1.doInternal(0x1492300, 0xc4200f84c0, 0xc4207f9780, 0x2, 0xe, 0x2, 0xc4207f9740, 0xe, 0xe, 0x1f, ...) /Users/zippo/develop/go/src/gopkg.in/readline.v1/complete_helper.go:120 +0x86d gopkg.in/readline%2ev1.doInternal(0x1492300, 0xc4200f8500, 0xc4207f9740, 0xe, 0xe, 0xe, 0xc4207f9740, 0xe, 0xe, 0xc420082008, ...) /Users/zippo/develop/go/src/gopkg.in/readline.v1/complete_helper.go:158 +0xaea gopkg.in/readline%2ev1.(*PrefixCompleter).Do(0xc4200f8500, 0xc4207f9740, 0xe, 0xe, 0xe, 0xe, 0x40, 0x1f, 0x0) /Users/zippo/develop/go/src/gopkg.in/readline.v1/complete_helper.go:104 +0x7e gopkg.in/readline%2ev1.(*opCompleter).OnComplete(0xc420131500) /Users/zippo/develop/go/src/gopkg.in/readline.v1/complete.go:78 +0x1b5 gopkg.in/readline%2ev1.(*Operation).ioloop(0xc420070660) /Users/zippo/develop/go/src/gopkg.in/readline.v1/operation.go:194 +0x6ba created by gopkg.in/readline%2ev1.NewOperation /Users/zippo/develop/go/src/gopkg.in/readline.v1/operation.go:82 +0x3b7
I know the reason:
I print some logs in the dynamic func:
fmt.Fprintf(tty.Stderr(), format, a...)
maybe these Fprintf cause the colWidth or candidateOff mismatched.
Fprintf
colWidth
candidateOff
Hi @chzyer , a strange panic:
colWidth is zero cause this panic, code is here: https://github.com/chzyer/readline/blob/master/complete.go#L205