-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deadlock when calling Wait and Go from different goroutines #6
Comments
@horgh Thanks for the kind words, much appreciated. It's great to see code in action. I'll freely admit I had not considered (or tested for) this scenario. It's very interesting. Just running through your example in my head, yes, I see the deadlock. It seems like it should be possible to distill this situation down to a test case, and easily arrive at that deadlock (I haven't done that yet, basically due to lack of time). I suppose the question is: if we had that test case, would Ideally, could you provide a test case that demonstrates the deadlock? Either which way, I want to get to the bottom of this scenario. It's a real-world situation that at a minimum needs to be documented, but hopefully solved. |
Thank you for looking at it! This reproduces the issue: package main
import (
"context"
"log"
"time"
"github.com/neilotoole/errgroup"
// "golang.org/x/sync/errgroup"
)
func main() {
ctx := context.Background()
eg, _ := errgroup.WithContext(ctx)
eg.Go(func() error { return g1(eg) })
if err := eg.Wait(); err != nil {
log.Fatal(err)
}
}
func g1(eg *errgroup.Group) error {
time.Sleep(100 * time.Millisecond)
eg.Go(func() error { return nil })
return nil
} When run this shows: It does not happen with |
I added a test here in the test package too - https://github.com/neilotoole/errgroup/compare/master...horgh:horgh/deadlock-test?expand=1 |
I'm kinda wondering now if |
Hi!
I'm using 0.1.5 with Go 1.16.3.
First, thank you for making the package! It's a great idea!
As to the issue: I've encountered what I believe is a deadlock due to my use of this package.
My program (a daemon) does this, among other things:
Periodically my program shuts down. As part of that, it calls Wait() on the errgroup.
The situation I have observed is this:
Stack traces:
What do you think?
The text was updated successfully, but these errors were encountered: