4 ms·
If all goroutines deadlock, then the runtime will panic and you'll get stack traces for everything. But yes, you can obviously deadlock one or more goroutines
by NateDad 12y ago
If all goroutines deadlock, then the runtime will panic and you'll get stack traces for everything. But yes, you can obviously deadlock one or more goroutines trivially. A simple select{} will just block one goroutine forever, for example. And no, there's no tools currently that will detect deadlocks, AFAIK.
- malkia 12y agoI haven't looked into that (or googled), but how does one detect that everything has deadlocked - is it some kind of profiling/sampling being done, or is it something more system specific? Any pointers? Thanks!
- f2f 12y ago"all goroutines are asleep - deadlock". https://code.google.com/p/go/source/browse/src/runtime/proc.c#2757 https://code.google.com/p/go/source/browse/src/runtime/proc....
- jesstaa 12y agohttp://golang.org/pkg/runtime/pprof/#Profile http://golang.org/pkg/runtime/pprof/#Profile Provides a "blocking profile" that tells you what things blocked and for how long they blocked for. You can use it to find places where you've deadlocked as well as places where adding buffered channels might help performance.
- mutation 12y agoIt seems that Go's race detector (https://blog.golang.org/race-detector https://blog.golang.org/race-detector) can do that. see an example: http://pastie.org/9705392 http://pastie.org/9705392