-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
panic: sync: negative WaitGroup counter #109
Comments
Fix in #110. |
actually, I had put the wg.Add(1) in front of the beginning, like this, still got the promblem. it happens occasionally, especially in parallel downloading.
|
Can u provide gopeed version? |
using the latest repo. |
There is no |
yeah, becuase I wanna custom the save file name, so i disable the automatic rename, so sure it will not trigger the panic: sync: negative WaitGroup counter |
I have tested your code and was unable to reproduce the issue. This exception is only triggered when calling wg.Add(1) after calling wg.Done(), but the code seem fine. |
using the following codes:
var wg sync.WaitGroup
_, err := download.Boot().
URL(args.url).
Listener(func(event *download.Event) {
if event.Key == download.EventKeyProgress {
printProgress(event.Task, "downloading...")
}
if event.Key == download.EventKeyFinally {
var title string
if event.Err != nil {
title = "fail"
} else {
title = "complete"
}
printProgress(event.Task, title)
fmt.Println()
if event.Err != nil {
fmt.Printf("reason: %s", event.Err.Error())
} else {
fmt.Printf("saving path: %s", *args.dir)
}
wg.Done()
}
}).
Create(&base.Options{
Path: *args.dir,
Extra: http.OptsExtra{Connections: *args.connections},
})
if err != nil {
panic(err)
}
wg.Add(1)
wg.Wait()
and got the panic: sync: negative WaitGroup counter error:
panic: sync: negative WaitGroup counter
goroutine 29685 [running]:
sync.(*WaitGroup).Add(0x1b28c40?, 0x4?)
/usr/local/go/src/sync/waitgroup.go:62 +0xe5
sync.(*WaitGroup).Done(...)
/usr/local/go/src/sync/waitgroup.go:87
media.downloadFile.func1(0xc00021f590)
/root/apps/netstream/gstream/media/downloader.go:51 +0x257
github.com/GopeedLab/gopeed/pkg/download.(*Downloader).emit(0xc000136660, {0x126257b, 0x7}, 0xc00083c780, {0xc00089ef58?, 0x10fe500?, 0xc00083ca00?})
/root/apps/netstream/gstream/thirdparty/gopeed/pkg/download/downloader.go:410 +0xe5
github.com/GopeedLab/gopeed/pkg/download.(*Downloader).watch(0xc000136660, 0xc00083c780)
/root/apps/netstream/gstream/thirdparty/gopeed/pkg/download/downloader.go:483 +0x134
github.com/GopeedLab/gopeed/pkg/download.(*Downloader).Create.func2()
/root/apps/netstream/gstream/thirdparty/gopeed/pkg/download/downloader.go:285 +0x90
created by github.com/GopeedLab/gopeed/pkg/download.(*Downloader).Create
/root/apps/netstream/gstream/thirdparty/gopeed/pkg/download/downloader.go:279 +0x6f8
The text was updated successfully, but these errors were encountered: