From 019bfc4e3520aa363246a9ea9d8d2e333758e58b Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 7 Mar 2021 23:35:19 +0900 Subject: [PATCH] Fix yet another deadlock EventBox.Set should not be called while holding the terminal mutex goroutine 1 [semacquire]: sync.runtime_SemacquireMutex(0xc0001923bc, 0x1000001066200, 0x1) /usr/local/Cellar/go/1.16/libexec/src/runtime/sema.go:71 +0x47 sync.(*Mutex).lockSlow(0xc0001923b8) /usr/local/Cellar/go/1.16/libexec/src/sync/mutex.go:138 +0x105 sync.(*Mutex).Lock(...) /usr/local/Cellar/go/1.16/libexec/src/sync/mutex.go:81 github.com/junegunn/fzf/src.(*Terminal).Input(0xc000192000, 0x0, 0x0, 0x0, 0x0) /fzf/src/terminal.go:581 +0x145 github.com/junegunn/fzf/src.Run.func10(0xc00010c8a0, 0xc000092050, 0xa) /fzf/src/core.go:245 +0x37 github.com/junegunn/fzf/src.Run.func11(0xc00011a4e0) /fzf/src/core.go:295 +0x5ce github.com/junegunn/fzf/src/util.(*EventBox).Wait(0xc00011a4e0, 0xc000127ec8) /fzf/src/util/eventbox.go:34 +0x5e github.com/junegunn/fzf/src.Run(0xc000180000, 0x11ac014, 0x6, 0x11ac158, 0x7) /fzf/src/core.go:251 +0xdac main.main() /fzf/main.go:13 +0x5a goroutine 11 [semacquire]: sync.runtime_SemacquireMutex(0xc00012c31c, 0xc00010e800, 0x1) /usr/local/Cellar/go/1.16/libexec/src/runtime/sema.go:71 +0x47 sync.(*Mutex).lockSlow(0xc00012c318) /usr/local/Cellar/go/1.16/libexec/src/sync/mutex.go:138 +0x105 sync.(*Mutex).Lock(0xc00012c318) /usr/local/Cellar/go/1.16/libexec/src/sync/mutex.go:81 +0x47 github.com/junegunn/fzf/src/util.(*EventBox).Set(0xc00011a4e0, 0x7, 0x114eb40, 0x1265460) /fzf/src/util/eventbox.go:40 +0x3b github.com/junegunn/fzf/src.(*Terminal).killPreview(0xc000192000, 0x0) /fzf/src/terminal.go:1831 +0xa5 github.com/junegunn/fzf/src.(*Terminal).exit(0xc000192000, 0xc000106e58) /fzf/src/terminal.go:1847 +0x75 github.com/junegunn/fzf/src.(*Terminal).Loop.func8.1(0xc00011a540) /fzf/src/terminal.go:2148 +0x38f github.com/junegunn/fzf/src/util.(*EventBox).Wait(0xc00011a540, 0xc000106f90) /fzf/src/util/eventbox.go:34 +0x5e github.com/junegunn/fzf/src.(*Terminal).Loop.func8(0xc000192000, 0xc00010a2c0) /fzf/src/terminal.go:2077 +0xa5 created by github.com/junegunn/fzf/src.(*Terminal).Loop /fzf/src/terminal.go:2072 +0x3e8 --- src/terminal.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/terminal.go b/src/terminal.go index b9d648df..34323a65 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -1844,9 +1844,9 @@ func (t *Terminal) exit(getCode func() int) { t.history.append(string(t.input)) } // prof.Stop() - t.killPreview(code) t.running = false t.mutex.Unlock() + t.killPreview(code) } // Loop is called to start Terminal I/O