Skip to content
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

Fix thread leak due to race condition #125

Merged
merged 3 commits into from
May 27, 2024
Merged

Fix thread leak due to race condition #125

merged 3 commits into from
May 27, 2024

Conversation

freyacodes
Copy link
Member

f602c47 fixes a thread leak in lavaplayer that appears to be caused by a race condition. I was able to reproduce the issue with some test code, with the leak no longer occurring after that commit. I can provide the test code used if relevant.

Specifically, the leak concerns LocalAudioTrackExecutor, which each control a thread. The audio buffer is leaked as well. This first commit makes the executor no longer reusable, meaning that once stopped a new one must be created, which happens automatically now.

However, I am still observing a similar leak of LocalAudioTrackExecutor when using Lavalink in a real working environment. 895b7cd was an attempt at eliminating places where the executor could leak. Heap analysis shows that the stop() function of LocalAudioTrackExecutor is not being called in rare cases, leading to a leak. Any help in resolving this second leak would be greatly appreciated. I suspect that these two leaks are separate issues, so merging this PR would likely still reduce the leak to an extent.

@devoxin
Copy link
Member

devoxin commented May 27, 2024

LGTM

@devoxin devoxin merged commit 8da0444 into main May 27, 2024
1 check passed
@devoxin devoxin deleted the thread-leak-pr branch May 27, 2024 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants