githubnemo / CompileDaemon

Very simple compile daemon for Go
BSD 2-Clause "Simplified" License
1.63k stars 156 forks source link

Fix deadlock after failed build #11

Closed dmage closed 9 years ago

dmage commented 9 years ago

Steps to reproduce:

  1. Run go run daemon.go process_posix.go -build="false" -command="pwd"
  2. Save multiple times daemon.go
  3. PROFIT!

Example of panic after detected deadlock:

fatal error: all goroutines are asleep - deadlock!

goroutine 1 [chan send]:
main.main()
    /Users/dmage/src/github.com/dmage/CompileDaemon/daemon.go:395 +0x903

goroutine 5 [chan send]:
github.com/howeyc/fsnotify.(*Watcher).readEvents(0x82033a000)
    /Users/dmage/.go/src/github.com/howeyc/fsnotify/fsnotify_bsd.go:368 +0xb96
created by github.com/howeyc/fsnotify.NewWatcher
    /Users/dmage/.go/src/github.com/howeyc/fsnotify/fsnotify_bsd.go:105 +0x57c

goroutine 6 [chan send]:
github.com/howeyc/fsnotify.(*Watcher).purgeEvents(0x82033a000)
    /Users/dmage/.go/src/github.com/howeyc/fsnotify/fsnotify.go:44 +0x1cd
created by github.com/howeyc/fsnotify.NewWatcher
    /Users/dmage/.go/src/github.com/howeyc/fsnotify/fsnotify_bsd.go:106 +0x59e

goroutine 17 [chan send]:
main.builder(0x8203ca060, 0x8203ca120, 0x8203ca0c0)
    /Users/dmage/src/github.com/dmage/CompileDaemon/daemon.go:176 +0xff
created by main.main
    /Users/dmage/src/github.com/dmage/CompileDaemon/daemon.go:379 +0x6d6

goroutine 18 [chan receive]:
main.runner(0x7fff5fbff768, 0x3, 0x8203ca120, 0x8203ca0c0)
    /Users/dmage/src/github.com/dmage/CompileDaemon/daemon.go:248 +0xd5
created by main.main
    /Users/dmage/src/github.com/dmage/CompileDaemon/daemon.go:382 +0x737

goroutine 19 [chan receive]:
main.logger(0x8203ca180)
    /Users/dmage/src/github.com/dmage/CompileDaemon/daemon.go:206 +0x53
created by main.runner
    /Users/dmage/src/github.com/dmage/CompileDaemon/daemon.go:243 +0x7a
exit status 2
githubnemo commented 9 years ago

Checks out. Thank you!

DavesPlanet commented 1 year ago

I reproduced this error with current development head after code I wrote caused a panic. Tried closing and restarting visual studio to no effect. Ah, interesting, deleting the generated EXE and re-running the daemon seems to have done it. Trying to file a good bug report so I explicity called panic in a controller and the daemon continued to operate as expected. Unreproduceable but still active bug. I've seen this a few times now so I'll keep an eye out for more information.

DavesPlanet commented 1 year ago

I have reproduced this bug after killing all processes, deleting my exe, logging out, and eventually restarting the computer. I can no longer make CompileDaemon, I just get the deadlock. And... its working again. I tried running CompileDaemon by itself, no other parameters, that worked, everything after that worked. Will continue to report back as I discover more.

fatal error: all goroutines are asleep - deadlock!

goroutine 1 [chan receive]: github.com/fsnotify/fsnotify.(*Watcher).Add(0xc00002e580, {0xc0005068b0?, 0x1?}) C:/Users/Me/go/pkg/mod/github.com/fsnotify/fsnotify@v1.4.9/windows.go:81 +0x108 main.NotifyWatcher.add(...) C:/Users/Me/go/pkg/mod/github.com/githubnemo/!compile!daemon@v1.4.0/watcher.go:86 main.addFiles.func1({0xc0005068b0, 0xf}, {0x942960?, 0xc0002d3c00?}, {0x0, 0x0}) C:/Users/Me/go/pkg/mod/github.com/githubnemo/!compile!daemon@v1.4.0/watcher.go:182 +0x127 path/filepath.walk({0xc0005068b0, 0xf}, {0x942960, 0xc0002d3c00}, 0xc000491e40) C:/Program Files/Go/src/path/filepath/path.go:484 +0xba path/filepath.walk({0xc00001a7e0, 0xc}, {0x942960, 0xc0001237a0}, 0xc000491e40) C:/Program Files/Go/src/path/filepath/path.go:504 +0x26f path/filepath.walk({0xc00001a318, 0x4}, {0x942960, 0xc000122690}, 0xc000491e40) C:/Program Files/Go/src/path/filepath/path.go:504 +0x26f path/filepath.walk({0xc00001a0cb, 0x1}, {0x942960, 0xc0001225b0}, 0xc000491e40) C:/Program Files/Go/src/path/filepath/path.go:504 +0x26f path/filepath.Walk({0xc00001a0cb, 0x1}, 0xc000107e40) C:/Program Files/Go/src/path/filepath/path.go:571 +0x6c main.addFiles({0x9428e0, 0xc000056140}) C:/Users/Me/go/pkg/mod/github.com/githubnemo/!compile!daemon@v1.4.0/watcher.go:174 +0xe8 main.NotifyWatcher.AddFiles(...) C:/Users/Me/go/pkg/mod/github.com/githubnemo/!compile!daemon@v1.4.0/watcher.go:56 main.main() C:/Users/Me/go/pkg/mod/github.com/githubnemo/!compile!daemon@v1.4.0/daemon.go:422 +0x406

goroutine 6 [select, locked to thread]: github.com/fsnotify/fsnotify.(Watcher).sendEvent(0xc00002e580, {0xc00016ba50?, 0xc000061d24?}, 0xfff?) C:/Users/Me/go/pkg/mod/github.com/fsnotify/fsnotify@v1.4.9/windows.go:522 +0xbc github.com/fsnotify/fsnotify.(Watcher).readEvents(0xc00002e580) C:/Users/Me/go/pkg/mod/github.com/fsnotify/fsnotify@v1.4.9/windows.go:488 +0xa90 created by github.com/fsnotify/fsnotify.NewWatcher C:/Users/Me/go/pkg/mod/github.com/fsnotify/fsnotify@v1.4.9/windows.go:46 +0x1d6