Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic: runtime error: slice bounds out of range (buffer_unix.go) #15

Open
rfay opened this issue Aug 1, 2018 · 2 comments
Open

panic: runtime error: slice bounds out of range (buffer_unix.go) #15

rfay opened this issue Aug 1, 2018 · 2 comments

Comments

@rfay
Copy link

rfay commented Aug 1, 2018

A long default in prompt.BasicDefault() results in a "panic: runtime error: slice bounds out of range", for example:

_, err = prompt.BasicDefault("Some Prompt (blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah ):", "somedefault")

Results in this panic:

Some Prompt (blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah ): (Default: somedefault) panic: runtime error: slice bounds out of range

goroutine 1 [running]:
github.com/drud/ddev/vendor/github.com/Bowery/prompt.(*Buffer).Refresh(0xc4201298a0, 0x1000, 0x1000)
	/go/src/github.com/drud/ddev/vendor/github.com/Bowery/prompt/buffer_unix.go:54 +0x4f1
github.com/drud/ddev/vendor/github.com/Bowery/prompt.(*Terminal).setup(0xc4202b17c0, 0xc4201298a0, 0x199af20, 0xc4202b81d0, 0x1fa86c8, 0x0, 0x0)
	/go/src/github.com/drud/ddev/vendor/github.com/Bowery/prompt/term.go:212 +0xa4
github.com/drud/ddev/vendor/github.com/Bowery/prompt.(*Terminal).prompt(0xc4202b17c0, 0xc4201298a0, 0x199af20, 0xc4202b81d0, 0x1, 0xc4200989a0, 0x153, 0xc420098991)
	/go/src/github.com/drud/ddev/vendor/github.com/Bowery/prompt/term.go:317 +0x67
github.com/drud/ddev/vendor/github.com/Bowery/prompt.(*Terminal).GetPrompt(0xc4202b17c0, 0xc420098840, 0x152, 0xc420129958, 0x10427c7, 0x0, 0xc420129970)
	/go/src/github.com/drud/ddev/vendor/github.com/Bowery/prompt/term.go:165 +0x11e
github.com/drud/ddev/vendor/github.com/Bowery/prompt.(*Terminal).Custom(0xc4202b17c0, 0xc420098840, 0x152, 0xc4201299c0, 0xb, 0x18d02bf, 0xb, 0x18c7cfd)
	/go/src/github.com/drud/ddev/vendor/github.com/Bowery/prompt/term.go:130 +0x82
github.com/drud/ddev/vendor/github.com/Bowery/prompt.(*Terminal).BasicDefault(0xc4202b17c0, 0x18f9c72, 0x13b, 0x18d02bf, 0xb, 0xc420577620, 0xc4202581e0, 0xc42018c280, 0x17657e0)
	/go/src/github.com/drud/ddev/vendor/github.com/Bowery/prompt/term.go:89 +0xda
github.com/drud/ddev/vendor/github.com/Bowery/prompt.BasicDefault(0x18f9c72, 0x13b, 0x18d02bf, 0xb, 0x0, 0x0, 0x0, 0x0)
	/go/src/github.com/drud/ddev/vendor/github.com/Bowery/prompt/prompt.go:51 +0xac
github.com/drud/ddev/pkg/ddevapp.(*DrudS3Provider).PromptForConfig(0xc42006b560, 0x0, 0x0)
	/go/src/github.com/drud/ddev/pkg/ddevapp/providerDrudS3.go:101 +0x9fe
github.com/drud/ddev/pkg/ddevapp.(*DdevApp).PromptForConfig(0xc420001380, 0xc420239cb0, 0xc420001380)
	/go/src/github.com/drud/ddev/pkg/ddevapp/config.go:258 +0x18c
github.com/drud/ddev/cmd/ddev/cmd.handleConfigRun(0x1dce4c0, 0x1dfb6d0, 0x0, 0x0)
	/go/src/github.com/drud/ddev/cmd/ddev/cmd/config.go:59 +0x4ce
github.com/drud/ddev/vendor/github.com/spf13/cobra.(*Command).execute(0x1dce4c0, 0x1dfb6d0, 0x0, 0x0, 0x1dce4c0, 0x1dfb6d0)
	/go/src/github.com/drud/ddev/vendor/github.com/spf13/cobra/command.go:766 +0x2c1
github.com/drud/ddev/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x1dd0140, 0x1003abc, 0xc420088058, 0x0)
	/go/src/github.com/drud/ddev/vendor/github.com/spf13/cobra/command.go:852 +0x30a
github.com/drud/ddev/vendor/github.com/spf13/cobra.(*Command).Execute(0x1dd0140, 0x0, 0xc4201a63a0)
	/go/src/github.com/drud/ddev/vendor/github.com/spf13/cobra/command.go:800 +0x2b
github.com/drud/ddev/cmd/ddev/cmd.Execute()
	/go/src/github.com/drud/ddev/cmd/ddev/cmd/root.go:105 +0x3b
main.main()
	/go/src/github.com/drud/ddev/cmd/ddev/main.go:6 +0x20
@larzconwell
Copy link
Member

I have a feeling this is because it runs more than one line in the terminal with just the prefix.

Unfortunately I don't have much time these days to take a look at this further. 😒 But If I can find some time I will take a look at it.

@tuvia-akeyless
Copy link

tuvia-akeyless commented Mar 12, 2023

i got panic with prompt.Custom when the prefix is bigger than 80 letters.
i checked with 75 letters and there was no panic.
looks like there is a bug in the code where you increase and decrease indexes:
start++ size-- pos--
reproduced only on linux OS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants