fix: To fix decoder lifetime during async decoding#711
Open
kaiqiy-nv wants to merge 1 commit into
Open
Conversation
Signed-off-by: Kaiqi Yan <kaiqiy@nvidia.com>
bmhowe23
reviewed
Jul 21, 2026
bmhowe23
left a comment
Collaborator
There was a problem hiding this comment.
Thanks, @kaiqiy-nv. We are close to a code freeze. Since this changes interfaces and the problematic use case appears to be not a primary use case, I'd like to hold off on this one for at least this week. Feel free to poke us about this in an about a week, though. Thanks!
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.
This PR tries to fix [B] 6479862.
It also adds 1 C++ test and 1 Python test to expose the bug and verify the fix.
Thanks for looking at this PR.
In this suggested fix:
[1] We keep the decoder alive for the full asynchronous operation.
We make
decodersupportshared_from_this(), returnshared_ptrfrom public decoder factories, and capture shared ownership indecode_asyncinstead of rawthis.Plugin creators keep
unique_ptrand convert ownership only at the factory boundary.[2] We update decoder storage and Python bindings to preserve shared ownership.
This avoids use-after-free when callers release a decoder before retrieving its asynchronous result.
We also add two test cases to expose this bug and verify the fix:
DecoderAsyncLifetime.PendingAsyncKeepsDecoderAlive: We block an instrumented decoder insidedecode(), release the caller’s decoder handle, and check that the destructor has not run. We then unblock the worker and verify its result.test_decode_async_temporary_keeps_decoder_alive: We calldecode_asyncon a temporary Python decoder and verify that.get()returns a valid result, proving that the temporary remains alive until decoding completes.