Repository navigation
Conversation
Freeing a frame-threaded decoder waits for its worker threads to finish. With logging enabled, `log_callback` takes the GIL for `AV_LOG_ERROR`, so a worker logging an error while `__dealloc__` held the GIL inside `avcodec_free_context` deadlocked the process. Free it with the GIL released, as `Container.__dealloc__` already does. Closes #2440
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes a deadlock when a frame-threaded decoder (
thread_type = "AUTO") is freed while its frame threads are still decoding and logging is enabled viaav.logging.set_level(...).CodecContext.__dealloc__held the GIL inavcodec_free_context, which waits for every frame thread to finish. A frame thread logging anAV_LOG_ERRORblocks inlog_callbackwaiting for the GIL, so neither thread could continue. The free now runs with the GIL released, matchingContainer.__dealloc__. The hwaccelget_formatcallback is nogil and only reads_private_data, which stays valid during__dealloc__.Verified with the reproducer from #2440 (HEVC, 2 worker threads,
set_level(FATAL)): it hung 2/2 runs before the change and finished 3/3 after.Closes #2440