signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x10fddebb6 (`AlecAivazis/survey/v2/terminal.(*RuneReader).ReadLineWithDefault`)
Description
┌─ user@c02fldw5md6m:~/Downloads
└──❯ nerdctl.lima ps -a
? Do you want to start the instance now? No
┌─ user@c02fldw5md6m:~/Downloads
└──❯ yes n | nerdctl.lima ps -a
? Do you want to start the instance now? (Y/n) ^[[55;214R^[[55;49Rpanic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x10fddebb6]
goroutine 1 [running]:
github.com/AlecAivazis/survey/v2/terminal.(*RuneReader).ReadLineWithDefault.func2(...)
github.com/AlecAivazis/survey/[email protected]/terminal/runereader.go:65
github.com/AlecAivazis/survey/v2/terminal.(*RuneReader).ReadLineWithDefault(0xc0005b46c0, 0x0, {0x1115a2f20, 0x0, 0x0}, {0x0?, 0xc000665340?, 0x10f359b25?})
github.com/AlecAivazis/survey/[email protected]/terminal/runereader.go:328 +0x976
github.com/AlecAivazis/survey/v2/terminal.(*RuneReader).ReadLine(...)
github.com/AlecAivazis/survey/[email protected]/terminal/runereader.go:37
github.com/AlecAivazis/survey/v2.(*Confirm).getBool(0xc00059e0b0, 0x0, 0xc0001ce308)
github.com/AlecAivazis/survey/[email protected]/confirm.go:59 +0x11e
github.com/AlecAivazis/survey/v2.(*Confirm).Prompt(0xc00059e0b0, 0xc0001ce308)
github.com/AlecAivazis/survey/[email protected]/confirm.go:137 +0xee
github.com/AlecAivazis/survey/v2.Ask({0xc0006657e0, 0x1, 0x4?}, {0x1102b94c0, 0xc0003d031c}, {0x0, 0x0, 0x10ffc2005?})
github.com/AlecAivazis/survey/[email protected]/survey.go:366 +0x3f3
github.com/AlecAivazis/survey/v2.AskOne(...)
github.com/AlecAivazis/survey/[email protected]/survey.go:283
github.com/lima-vm/lima/v2/pkg/uiutil.Confirm({0x110013b7d, 0x27}, 0x1)
github.com/lima-vm/lima/v2/pkg/uiutil/uiutil.go:24 +0xe6
main.askWhetherToStart(...)
github.com/lima-vm/lima/v2/cmd/limactl/edit.go:185
main.shellAction(0xc00054af08, {0xc000544aa0, 0x4, 0x5})
github.com/lima-vm/lima/v2/cmd/limactl/shell.go:104 +0x439
github.com/spf13/cobra.(*Command).execute(0xc00054af08, {0xc000544a50, 0x5, 0x5})
github.com/spf13/[email protected]/command.go:1015 +0xb02
github.com/spf13/cobra.(*Command).ExecuteC(0xc00054a308)
github.com/spf13/[email protected]/command.go:1148 +0x465
github.com/spf13/cobra.(*Command).Execute(...)
github.com/spf13/[email protected]/command.go:1071
main.main()
github.com/lima-vm/lima/v2/cmd/limactl/main.go:50 +0x6f
┌─ user@c02fldw5md6m:~/Downloads [SIGPIPE|2]
└──❯
Update: Adding the "-y" option had no effect; the panic still occurred.
-y, --yes Alias of --tty=false
Some more information on the environment would help with reproducing.
└──❯ uname -a
Darwin 25.1.0 Darwin Kernel Version 25.1.0: Mon Oct 20 19:26:51 PDT 2025; root:xnu-12377.41.6~2/RELEASE_X86_64 x86_64 Darwin
└──❯ limactl --version
limactl version 2.0.2
└──❯ fish --version
fish, version 4.2.1
There is missing error handling in the library, and it doesn't cope with stdin being a tty (added panic):
// we get the terminal width and height (if resized after this point the property might become invalid)
terminalSize, _ := cursor.Size(rr.Buffer())
// we set the current location of the cursor once
cursorCurrent, _ := cursor.Location(rr.Buffer())
increment := func() {
if cursorCurrent.CursorIsAtLineEnd(terminalSize) {
cursorCurrent.X = COORDINATE_SYSTEM_BEGIN
cursorCurrent.Y++
} else {
cursorCurrent.X++
}
}
decrement := func() {
if cursorCurrent.CursorIsAtLineBegin() {
cursorCurrent.X = terminalSize.X
cursorCurrent.Y--
} else {
cursorCurrent.X--
}
}
// we get the terminal width and height (if resized after this point the property might become invalid)
terminalSize, err := cursor.Size(rr.Buffer())
if err != nil {
panic(fmt.Sprintf("cursor.Size: %v", err))
}
// we set the current location of the cursor once
cursorCurrent, err := cursor.Location(rr.Buffer())
if err != nil {
panic(fmt.Sprintf("cursor.Location: %v", err))
}
? Do you want to start the instance now? (Y/n) panic: cursor.Size: bufio: buffer full
Since the survey library is frozen, should probably bail out already in uiutil when there is no TTY?
- https://github.com/lima-vm/lima/issues/1881
Adding the "-y" option had no effect; the panic still occurred.
The "limactl shell" command doesn't check the tty flag, like "limactl edit" and "limactl clone" do (when checking start flag).
This check should be added, even though there also needs to be a better default when checking InputIsTTY as well
@afbjorklund I would like to work on this issue.
I think with above changes that it is done, but I can invite you to the code review if you want to improve it further?
Since the survey library is frozen, should probably bail out already in uiutil when there is no TTY?
This check should be added, even though there also needs to be a better default when checking InputIsTTY as well
- #4416