c-bata / go-prompt

Building powerful interactive prompts in Go, inspired by python-prompt-toolkit.
https://godoc.org/github.com/c-bata/go-prompt
MIT License
5.3k stars 350 forks source link

[Bug] panic: runtime error: integer divide by zero #277

Open rsivasamgit opened 1 year ago

rsivasamgit commented 1 year ago

Bug reports

We are using go-prompt and once in a while when we get into the CLI prompt, a "divide by zero" error is seen

panic: runtime error: integer divide by zero

goroutine 1 [running]: github.com/c-bata/go-prompt.(Render).toPos(...) /go/pkg/mod/github.com/c-bata/go-prompt@v0.2.6/render.go:269 github.com/c-bata/go-prompt.(Render).move(0x0?, 0x0?, 0xc00006f8b8?) /go/pkg/mod/github.com/c-bata/go-prompt@v0.2.6/render.go:258 +0xbb github.com/c-bata/go-prompt.(Render).clear(0xc0004b8ea0, 0x17487af?) /go/pkg/mod/github.com/c-bata/go-prompt@v0.2.6/render.go:245 +0x25 github.com/c-bata/go-prompt.(Render).BreakLine(0xc0004b8ea0, 0xc000424140) /go/pkg/mod/github.com/c-bata/go-prompt@v0.2.6/render.go:229 +0x22d github.com/c-bata/go-prompt.(Prompt).feed(0xc0000e6000, {0xc0004f9800, 0x1, 0x400}) /go/pkg/mod/github.com/c-bata/go-prompt@v0.2.6/prompt.go:124 +0x2fa github.com/c-bata/go-prompt.(Prompt).Run(0xc0000e6000) /go/pkg/mod/github.com/c-bata/go-prompt@v0.2.6/prompt.go:71 +0x525 bitbucket.rks-cloud.com/edge/seinfra-common-app/pkg/cobrashell.New.func1(0xc000468600?, {0x173ef40?, 0x0?, 0x0?}) /stage/pkg/cobrashell/shell.go:62 +0xf2 github.com/spf13/cobra.(Command).execute(0xc000468600, {0x24b6e68, 0x0, 0x0}) /go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:944 +0x847 github.com/spf13/cobra.(Command).ExecuteC(0x246d000) /go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:1068 +0x3bc github.com/spf13/cobra.(*Command).Execute(...) /go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:992

The issue is not seen always, it is seen once in every 6 attempts or so and rest of the time, the CLI renders properly

RainyBow commented 5 months ago

if terminal is console or serial ,it will happen