[vpdq] Ensure VpdqHasher joins threads on destruction #1608
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.
Summary
VpdqHasher
currently doesn't join its hashing threads on destruction.This is a problem if
VpdqHasher::finish()
is not called and VpdqHasher is destroyed. The threads will be destroyed while not joined which causes an abort.Also remove the template specialization code so that this file doesn't depend on FFmpeg libraries at all. These aren't necessary after #1605.
I spotted this while integrating vpdq in another project. I was using Python bindings and when an exception occurred from Python during hashing the entire program would deadlock.
Test Plan
Current regtest doesn't cover this because
finish()
is always called infilehasher.cpp
. This would be something for a unit test.But I tested by removing the
finish()
call infilehasher.cpp
and ran regtest with TSan. Before there was an abort and now there isn't.Also tested with my other project and it fixed the deadlock issue immediately.
Thanks!