Fix thread leak due to race condition #125
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 thestop()
function ofLocalAudioTrackExecutor
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.