chzyer / readline

Readline is a pure go(golang) implementation for GNU-Readline kind library
MIT License
2.1k stars 280 forks source link

data race in history search #219

Open slingamn opened 1 year ago

slingamn commented 1 year ago

With the test case in #217 against v1.5.1 / 7f93d88cd5ffa0e805d58d2f9fc3191be15ec668 (after entering some commands and mashing Ctrl-R a couple times):

> ==================
WARNING: DATA RACE
Write at 0x00c00013e080 by goroutine 13:
  github.com/chzyer/readline.(*opSearch).SearchMode()
      github.com/chzyer/readline/search.go:104 +0x66
  github.com/chzyer/readline.(*Operation).ioloop()
      github.com/chzyer/readline/operation.go:188 +0x1cfd
  github.com/chzyer/readline.NewOperation.func2()
      github.com/chzyer/readline/operation.go:88 +0x39

Previous read at 0x00c00013e080 by main goroutine:
  github.com/chzyer/readline.(*opSearch).IsSearchMode()
      github.com/chzyer/readline/search.go:50 +0x199
  github.com/chzyer/readline.(*wrapWriter).Write()
      github.com/chzyer/readline/operation.go:60 +0x158
  github.com/chzyer/readline.(*Instance).Write()
      github.com/chzyer/readline/readline.go:298 +0xeb
  fmt.Fprintf()
      fmt/print.go:225 +0xb1
  main.main()
      minimal.go:57 +0x513

Goroutine 13 (running) created at:
  github.com/chzyer/readline.NewOperation()
      github.com/chzyer/readline/operation.go:88 +0x904
  github.com/chzyer/readline.(*Terminal).Readline()
      github.com/chzyer/readline/terminal.go:95 +0x5b
  github.com/chzyer/readline.NewEx()
      github.com/chzyer/readline/readline.go:169 +0x41
  github.com/chzyer/readline.New()
      github.com/chzyer/readline/readline.go:181 +0x10e
  main.main()
      minimal.go:16 +0x56
==================