panjf2000 / ants

🐜🐜🐜 ants is the most powerful and reliable pooling solution for Go.
https://ants.andypan.me/
MIT License
12.83k stars 1.36k forks source link

[Bug]: Potential goroutine leak in pool.go #276

Closed hhheiaenia closed 1 year ago

hhheiaenia commented 1 year ago

Actions I've taken before I'm here

What happened?

I notice the ctx.Done() needs a cancel function to unblock the statement of ctx.Done in https://github.com/panjf2000/ants/blob/dev/pool.go#LL84C21-L84C21, but I never find the cancel function in its invocation. So if this may leak the goroutine where the ctx.Done() locates?

Maybe what I said is not right, thank you.

Major version of ants

v2

Specific version of ants

v2.6.0

Operating system

Linux

Relevant log output

.

Code snippets (optional)

.

How to Reproduce

.

Does this issue reproduce with the latest release?

I haven't verified it with the latest release

panjf2000 commented 1 year ago

Check out this:

https://github.com/panjf2000/ants/blob/9fdd99a7b4b568d102ea85a62341641bacfc5827/pool.go#L293-L296

hhheiaenia commented 1 year ago

You can refer to these link: https://www.arangodb.com/2020/09/a-story-of-a-memory-leak-in-go-how-to-properly-use-time-after/ https://github.com/eclipse/paho.mqtt.golang/issues/518

panjf2000 commented 1 year ago

I've read the article you provided and failed to see whatever you were seeing for memory leak, that article was talking about time.After which ants never uses.