walles / moar

Moar is a pager. It's designed to just do the right thing without any configuration.
Other
600 stars 17 forks source link

Fix shutdown hang #37

Closed walles closed 3 years ago

walles commented 3 years ago

Try this

Current result

moar closes its display, but then hangs without giving any prompt back. Ctrl-C doesn't help, it has to be killed.

Expected result

A clean exit.

walles commented 3 years ago

This feels like a deadlock between waiting for events in two different places:

Next step should be to make a small repro and send to upstream, I'm guessing this is an upstream issue.

Thread dump

Constructed using this trick.

goroutine 53 [running]:
runtime/pprof.writeGoroutineStacks(0x17f6980, 0xc000584380, 0xc0005c7770, 0x0)
    /usr/local/Cellar/go/1.15.6/libexec/src/runtime/pprof/pprof.go:693 +0x9f
runtime/pprof.writeGoroutine(0x17f6980, 0xc000584380, 0x2, 0x1b3cf20, 0xc0004e6580)
    /usr/local/Cellar/go/1.15.6/libexec/src/runtime/pprof/pprof.go:682 +0x45
runtime/pprof.(*Profile).WriteTo(0x1b3fd60, 0x17f6980, 0xc000584380, 0x2, 0xc000584380, 0xc0001279d8)
    /usr/local/Cellar/go/1.15.6/libexec/src/runtime/pprof/pprof.go:331 +0x3f2
net/http/pprof.handler.ServeHTTP(0xc0000284c1, 0x9, 0x17fda00, 0xc000584380, 0xc00022a600)
    /usr/local/Cellar/go/1.15.6/libexec/src/net/http/pprof/pprof.go:256 +0x385
net/http/pprof.Index(0x17fda00, 0xc000584380, 0xc00022a600)
    /usr/local/Cellar/go/1.15.6/libexec/src/net/http/pprof/pprof.go:367 +0x945
net/http.HandlerFunc.ServeHTTP(0x176a668, 0x17fda00, 0xc000584380, 0xc00022a600)
    /usr/local/Cellar/go/1.15.6/libexec/src/net/http/server.go:2042 +0x44
net/http.(*ServeMux).ServeHTTP(0x1b58d40, 0x17fda00, 0xc000584380, 0xc00022a600)
    /usr/local/Cellar/go/1.15.6/libexec/src/net/http/server.go:2417 +0x1ad
net/http.serverHandler.ServeHTTP(0xc0008a40e0, 0x17fda00, 0xc000584380, 0xc00022a600)
    /usr/local/Cellar/go/1.15.6/libexec/src/net/http/server.go:2843 +0xa3
net/http.(*conn).serve(0xc00027c000, 0x17fe8c0, 0xc0004b4040)
    /usr/local/Cellar/go/1.15.6/libexec/src/net/http/server.go:1925 +0x8ad
created by net/http.(*Server).Serve
    /usr/local/Cellar/go/1.15.6/libexec/src/net/http/server.go:2969 +0x36c

goroutine 1 [chan receive]:
github.com/gdamore/tcell/v2.(*tScreen).termioFini(0xc0002b7200)
    /Users/johan/go/pkg/mod/github.com/gdamore/tcell/v2@v2.0.0/tscreen_darwin.go:106 +0x54
github.com/gdamore/tcell/v2.(*tScreen).finish(0xc0002b7200)
    /Users/johan/go/pkg/mod/github.com/gdamore/tcell/v2@v2.0.0/tscreen.go:497 +0x275
sync.(*Once).doSlow(0xc0002b73c4, 0xc000123da0)
    /usr/local/Cellar/go/1.15.6/libexec/src/sync/once.go:66 +0xec
sync.(*Once).Do(...)
    /usr/local/Cellar/go/1.15.6/libexec/src/sync/once.go:57
github.com/gdamore/tcell/v2.(*tScreen).Fini(0xc0002b7200)
    /Users/johan/go/pkg/mod/github.com/gdamore/tcell/v2@v2.0.0/tscreen.go:469 +0x6a
main.startPaging.func1(0x18035e0, 0xc0002b7200, 0xc00088c020)
    /Users/johan/src/moar/moar.go:156 +0x35
main.startPaging(0xc0000701e0)
    /Users/johan/src/moar/moar.go:176 +0x139
main.main()
    /Users/johan/src/moar/moar.go:144 +0x335

goroutine 50 [syscall]:
os/signal.signal_recv(0x0)
    /usr/local/Cellar/go/1.15.6/libexec/src/runtime/sigqueue.go:144 +0x9d
os/signal.loop()
    /usr/local/Cellar/go/1.15.6/libexec/src/os/signal/signal_unix.go:23 +0x25
created by os/signal.Notify.func1.1
    /usr/local/Cellar/go/1.15.6/libexec/src/os/signal/signal.go:150 +0x45

goroutine 23 [IO wait]:
internal/poll.runtime_pollWait(0x9569000, 0x72, 0x0)
    /usr/local/Cellar/go/1.15.6/libexec/src/runtime/netpoll.go:222 +0x55
internal/poll.(*pollDesc).wait(0xc0002ea998, 0x72, 0x0, 0x0, 0x1696535)
    /usr/local/Cellar/go/1.15.6/libexec/src/internal/poll/fd_poll_runtime.go:87 +0x45
internal/poll.(*pollDesc).waitRead(...)
    /usr/local/Cellar/go/1.15.6/libexec/src/internal/poll/fd_poll_runtime.go:92
internal/poll.(*FD).Accept(0xc0002ea980, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.15.6/libexec/src/internal/poll/fd_unix.go:394 +0x1fc
net.(*netFD).accept(0xc0002ea980, 0xd12de411cd93dea0, 0x1070dcd93dea0, 0x100000001)
    /usr/local/Cellar/go/1.15.6/libexec/src/net/fd_unix.go:172 +0x45
net.(*TCPListener).accept(0xc00000e960, 0x5ffbe98d, 0xc000057e00, 0x10ca4c6)
    /usr/local/Cellar/go/1.15.6/libexec/src/net/tcpsock_posix.go:139 +0x32
net.(*TCPListener).Accept(0xc00000e960, 0xc000057e50, 0x18, 0xc00041c000, 0x136160c)
    /usr/local/Cellar/go/1.15.6/libexec/src/net/tcpsock.go:261 +0x65
net/http.(*Server).Serve(0xc0008a40e0, 0x17fd780, 0xc00000e960, 0x0, 0x0)
    /usr/local/Cellar/go/1.15.6/libexec/src/net/http/server.go:2937 +0x266
net/http.(*Server).ListenAndServe(0xc0008a40e0, 0xc0008a40e0, 0x0)
    /usr/local/Cellar/go/1.15.6/libexec/src/net/http/server.go:2866 +0xb7
net/http.ListenAndServe(...)
    /usr/local/Cellar/go/1.15.6/libexec/src/net/http/server.go:3120
github.com/walles/moar/m.(*Pager).StartPaging.func1()
    /Users/johan/src/moar/m/pager.go:679 +0x58
created by github.com/walles/moar/m.(*Pager).StartPaging
    /Users/johan/src/moar/m/pager.go:678 +0x47

goroutine 54 [IO wait]:
internal/poll.runtime_pollWait(0x9568e30, 0x72, 0x17f7800)
    /usr/local/Cellar/go/1.15.6/libexec/src/runtime/netpoll.go:222 +0x55
internal/poll.(*pollDesc).wait(0xc0002eae98, 0x72, 0x17f7800, 0x1b00908, 0x0)
    /usr/local/Cellar/go/1.15.6/libexec/src/internal/poll/fd_poll_runtime.go:87 +0x45
internal/poll.(*pollDesc).waitRead(...)
    /usr/local/Cellar/go/1.15.6/libexec/src/internal/poll/fd_poll_runtime.go:92
internal/poll.(*FD).Read(0xc0002eae80, 0xc00080a000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.15.6/libexec/src/internal/poll/fd_unix.go:159 +0x1a5
net.(*netFD).Read(0xc0002eae80, 0xc00080a000, 0x1000, 0x1000, 0xc0000cc240, 0xc0000597c0, 0x1356465)
    /usr/local/Cellar/go/1.15.6/libexec/src/net/fd_posix.go:55 +0x4f
net.(*conn).Read(0xc000208038, 0xc00080a000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.15.6/libexec/src/net/net.go:182 +0x8e
net/http.(*connReader).Read(0xc000892360, 0xc00080a000, 0x1000, 0x1000, 0x10000000e, 0x104bb5f, 0x9291888)
    /usr/local/Cellar/go/1.15.6/libexec/src/net/http/server.go:798 +0x1ad
bufio.(*Reader).fill(0xc0004a6480)
    /usr/local/Cellar/go/1.15.6/libexec/src/bufio/bufio.go:101 +0x105
bufio.(*Reader).ReadSlice(0xc0004a6480, 0xa, 0x9291888, 0xc000059988, 0x100f6d0, 0xc00022a500, 0x100)
    /usr/local/Cellar/go/1.15.6/libexec/src/bufio/bufio.go:360 +0x3d
bufio.(*Reader).ReadLine(0xc0004a6480, 0xc00022a500, 0x1b89f3c, 0xc000600480, 0x0, 0x1010038, 0x30)
    /usr/local/Cellar/go/1.15.6/libexec/src/bufio/bufio.go:389 +0x34
net/textproto.(*Reader).readLineSlice(0xc0008923c0, 0xc00022a500, 0x10d450d, 0xc0002eae80, 0x2000, 0xc00000ea60)
    /usr/local/Cellar/go/1.15.6/libexec/src/net/textproto/reader.go:58 +0x6c
net/textproto.(*Reader).ReadLine(...)
    /usr/local/Cellar/go/1.15.6/libexec/src/net/textproto/reader.go:39
net/http.readRequest(0xc0004a6480, 0x0, 0xc00022a500, 0x0, 0x0)
    /usr/local/Cellar/go/1.15.6/libexec/src/net/http/request.go:1012 +0xaa
net/http.(*conn).readRequest(0xc00027c0a0, 0x17fe8c0, 0xc0000cc0c0, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.15.6/libexec/src/net/http/server.go:984 +0x19a
net/http.(*conn).serve(0xc00027c0a0, 0x17fe8c0, 0xc0000cc0c0)
    /usr/local/Cellar/go/1.15.6/libexec/src/net/http/server.go:1851 +0x705
created by net/http.(*Server).Serve
    /usr/local/Cellar/go/1.15.6/libexec/src/net/http/server.go:2969 +0x36c

goroutine 51 [chan send]:
github.com/gdamore/tcell/v2.(*tScreen).PostEventWait(...)
    /Users/johan/go/pkg/mod/github.com/gdamore/tcell/v2@v2.0.0/tscreen.go:969
github.com/gdamore/tcell/v2.(*tScreen).scanInput(0xc0002b7200, 0xc00079ff00, 0x1b58f00)
    /Users/johan/go/pkg/mod/github.com/gdamore/tcell/v2@v2.0.0/tscreen.go:1323 +0xa7
github.com/gdamore/tcell/v2.(*tScreen).mainLoop(0xc0002b7200)
    /Users/johan/go/pkg/mod/github.com/gdamore/tcell/v2@v2.0.0/tscreen.go:1447 +0x30f
created by github.com/gdamore/tcell/v2.(*tScreen).Init
    /Users/johan/go/pkg/mod/github.com/gdamore/tcell/v2@v2.0.0/tscreen.go:185 +0x631

goroutine 52 [chan send]:
github.com/gdamore/tcell/v2.(*tScreen).inputLoop(0xc0002b7200)
    /Users/johan/go/pkg/mod/github.com/gdamore/tcell/v2@v2.0.0/tscreen.go:1473 +0x6e
created by github.com/gdamore/tcell/v2.(*tScreen).Init
    /Users/johan/go/pkg/mod/github.com/gdamore/tcell/v2@v2.0.0/tscreen.go:186 +0x656

goroutine 9 [chan receive (nil chan)]:
github.com/walles/moar/m.(*Pager).StartPaging.func2(0xc0000d02a0, 0x18035e0, 0xc0002b7200)
    /Users/johan/src/moar/m/pager.go:700 +0x7d
created by github.com/walles/moar/m.(*Pager).StartPaging
    /Users/johan/src/moar/m/pager.go:697 +0x1d1

goroutine 12 [IO wait]:
internal/poll.runtime_pollWait(0x9568f18, 0x72, 0x17f7800)
    /usr/local/Cellar/go/1.15.6/libexec/src/runtime/netpoll.go:222 +0x55
internal/poll.(*pollDesc).wait(0xc0002ead18, 0x72, 0x17f7800, 0x1b00908, 0x0)
    /usr/local/Cellar/go/1.15.6/libexec/src/internal/poll/fd_poll_runtime.go:87 +0x45
internal/poll.(*pollDesc).waitRead(...)
    /usr/local/Cellar/go/1.15.6/libexec/src/internal/poll/fd_poll_runtime.go:92
internal/poll.(*FD).Read(0xc0002ead00, 0xc0005c6041, 0x1, 0x1, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.15.6/libexec/src/internal/poll/fd_unix.go:159 +0x1a5
net.(*netFD).Read(0xc0002ead00, 0xc0005c6041, 0x1, 0x1, 0xc0004b4658, 0xc000511f68, 0x10866dc)
    /usr/local/Cellar/go/1.15.6/libexec/src/net/fd_posix.go:55 +0x4f
net.(*conn).Read(0xc000208030, 0xc0005c6041, 0x1, 0x1, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.15.6/libexec/src/net/net.go:182 +0x8e
net/http.(*connReader).backgroundRead(0xc0005c6030)
    /usr/local/Cellar/go/1.15.6/libexec/src/net/http/server.go:690 +0x58
created by net/http.(*connReader).startBackgroundRead
    /usr/local/Cellar/go/1.15.6/libexec/src/net/http/server.go:686 +0xd5