model, feature: clean up option dictionaries on failure - #1588
Open
lusoris wants to merge 2 commits into
Open
Conversation
This was referenced Sep 8, 2026
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.
Feature-option overloads leak supplied dictionaries when merging fails; collection overloads can leak partial copies and return success. Feature registration has related failure paths: copied dictionaries survive copy/create errors, and an invalid option leaves the constructor's context, extractor descriptor and private storage allocated. Callers also bind backend/frame-sync state before checking whether creation succeeded.
This change releases owned allocations, propagates errors, and publishes a feature context only after successful construction. It extends the focused overload cleanup from VMAFx #1223. Related to #1242; it does not redesign or deprecate the API.
Ownership documentation preserves the existing distinctions:
vmaf_use_feature()retains its supplied dictionary on argument/name rejection or failure to copy it. Once copying succeeds, it consumes that dictionary even if subsequent validation/registration fails. The error code alone cannot distinguish these stages.Tests cover natural invalid-option rejection and retry, constructor publication and all three constructor allocation failures, explicit/model partial-copy cleanup, and explicit/model context-create failure. The existing
test_contextexecutable is now registered with Meson. Deterministic allocation tests use GNU link wrapping on Linux static builds; no production test hooks or C++ runtime helpers are added.Validation against upstream
f85a853692a8c730d0270cd733c8bb30b5b93b7c(libvmaf 3.2.0), x86-64 Linux, GCC 15.2, Meson 1.10.1, C11:Negative controls preserve the original implementations. A real public model-registration probe leaks 554 bytes in seven allocations with the original shared library and is clean with the fixed library. The new constructor test fails because the original publishes a failed context; the partial-copy test fails because the original does not free the copy. Earlier overload controls also fail on the original merge/copy paths.
Worker failure paths were source-reviewed, not covered by injected runtime worker failures. Unrelated private pool defects are outside this change. The previously recorded full sanitizer baseline had existing leaks in
test_predictandtest_pic_preallocation; this update reruns the ownership-focused sanitizer set and does not claim a green full sanitizer suite. No Netflix golden assertion, score calculation or GPU runtime validation is changed or claimed.