chzyer / readline

Readline is a pure go(golang) implementation for GNU-Readline kind library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crash after Ctrl-S, Ctrl-C

firelizzard18 opened this issue · comments

Given this program:

package main

import (
	"fmt"
	"log"

	"github.com/chzyer/readline"
)

func main() {
	log.SetFlags(log.LstdFlags | log.Lshortfile)

	rl, err := readline.New("> ")
	if err != nil {
		log.Fatal(err)
	}

	line, err := rl.Readline()
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(line)
}

Typing Ctrl-S followed by Ctrl-C will cause:

> panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x10b8912]

goroutine 35 [running]:
github.com/chzyer/readline.(*opSearch).ExitSearchMode(0xc0000c4080, 0xc000106101)
        /XXX/pkg/mod/github.com/chzyer/readline@v0.0.0-20180603132655-2972be24d48e/search.go:118 +0x52
github.com/chzyer/readline.(*Operation).ioloop(0xc0000d4000)
        /XXX/pkg/mod/github.com/chzyer/readline@v0.0.0-20180603132655-2972be24d48e/operation.go:302 +0x935
created by github.com/chzyer/readline.NewOperation
        /XXX/pkg/mod/github.com/chzyer/readline@v0.0.0-20180603132655-2972be24d48e/operation.go:88 +0x2b1
exit status 2

FWIW just tried this, but wasn't able to reproduce with the latest master.

reproduced in win11