Closed xuxiaofan1203 closed 4 months ago
It's supposed to be blocking when a pool starts, and then loop periodically to clean up idle workers. The context will be cancelled when you call Release()
.
It's supposed to be blocking when a pool starts, and then loop periodically to clean up idle workers. The context will be cancelled when you call
Release()
.
Thank you for your reply. I read the relative codes carefully again, a potential goleak due to lacking of cancelFunc in Release() has been fixed in https://github.com/panjf2000/ants/pull/287 successfully. I suppose it's right in the current version, and maybe it is a false positive reported by goleak.
Actions I've taken before I'm here
What happened?
Hello @panjf2000 , When I ran the test file,https://github.com/panjf2000/ants/blob/34ff2c228286420cfdadf2a6f8b7b7a108952d02/ants_test.go#L53 I found a potential bug. When the Newpool() get executed https://github.com/panjf2000/ants/blob/34ff2c228286420cfdadf2a6f8b7b7a108952d02/ants_test.go#L55 The goroutine will block at the select statement, I think the reason is that maybe there is no cancelFunc to awaken the ctx.Done(), which results in the select blocking. So the goroutine leak. https://github.com/panjf2000/ants/blob/34ff2c228286420cfdadf2a6f8b7b7a108952d02/pool.go#L84-L88
Major version of ants
v2
Specific version of ants
latest version
Operating system
Linux
OS version
Ubuntu 22.04.3 LTS
Go version
Go 1.21.7
Relevant log output
Code snippets (optional)
No response
How to Reproduce
You can use goleak to reproduce the bug easily like this
![1714224116230](https://github.com/panjf2000/ants/assets/61485003/caffdbc9-9b33-4d0a-b4b3-acabc81d4abc)
Does this issue reproduce with the latest release?
It can reproduce with the latest release