Repository navigation
Conversation
lusoris
marked this pull request as ready for review
May 30, 2026 23:48
lusoris
enabled auto-merge (squash)
May 30, 2026 23:48
lusoris
marked this pull request as draft
May 31, 2026 00:52
auto-merge was automatically disabled
May 31, 2026 00:52
Pull request was converted to draft
lusoris
marked this pull request as ready for review
May 31, 2026 01:46
lusoris
enabled auto-merge (squash)
May 31, 2026 01:46
auto-merge was automatically disabled
May 31, 2026 01:46
Pull request was closed
lusoris
force-pushed
the
fix/memory-allocator-audit
branch
from
May 31, 2026 01:46
3ac60d4 to
e81b133
Compare
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.
Summary
Audit of fork-added CPU feature-extractor
init()paths against CERT MEM31-C. Framework-level invariant rediscovered:vmaf_feature_extractor_context_destroy()frees theprivstruct itself but NEVER invokes the extractor'sclose()callback wheninit()returned non-zero (theis_initializedgate stays false). Four leak clusters fixed; ASan + leak-detect clean across fast suite (49/49) and full suite (63/63) + e2e cambi/ssimulacra2/motion runs. Zero golden-data drift (CPU path is allocator-only, no math touched).Type
fix— bug fixPer-site root cause
core/src/feature/ssimulacra2.c::initaligned_malloc(ref_lin, dist_lin, ref_xyb, dist_xyb, mu1, mu2, sigma1_sq, sigma2_sq, sigma12, mul_buf, scratch, col_state)aligned_free()sequence +memset(s, 0, sizeof(*s))beforereturn -ENOMEMcore/src/feature/cambi.c::initaligned_malloc+feature_name_dict+ up to 3 × heatmapFILE*cambi_init_release_partials()mirroringclose_cambi(); converted every error return toerr = ...; goto failcore/src/feature/cambi.c::set_contrast_arraysaligned_malloc+ previously-uncaught return codecore/src/feature/integer_motion_v2.c::initfeature_name_dicts->y_rowallocation failsChecklist
clang-format+pre-commit run --files <touched>green locally.meson test -C build-mem --suite=fast(49/49 OK) and full suite (63/63 OK)..c/.hfiles added.Bug-status hygiene (ADR-0165)
docs/state.mdupdated withT-MEMORY-ALLOCATOR-AUDIT-INIT-OOM-2026-05-30row at the top.Netflix golden-data gate (ADR-0024)
assertAlmostEqual(...)score in the Netflix golden Python tests.Cross-backend numerical results
Deep-dive deliverables (ADR-0108)
docs/research/memory-allocator-audit-2026-05-30.mdwalks the 355-site enumeration, the audited clusters, the framework invariant, and the per-cluster verdict.docs/adr/0906-memory-allocator-audit-cleanup.md## Alternatives consideredlists the four candidate fix strategies (inline helper + goto fail / framework-level close-on-fail / caller-allocated priv / no fix) with pros, cons, and rejection rationale.AGENTS.mdinvariant note —core/src/feature/AGENTS.md## Rebase-sensitive invariantsnow documents the framework-level rule thatinit()must drain partials on every error return; referencestransnet_v2.c::release_buffers,feature_lpips.c::lpips_release, and the newcambi.c::cambi_init_release_partialsas templates.changelog.d/fixed/memory-allocator-audit.md.docs/rebase-notes.mdunder "Memory allocator audit — init() OOM-cleanup (2026-05-30, ADR-0906)" describing the medium rebase impact oncambi.c(upstream port that grows the buffer list must extend the cleanup helper in lock-step) and zero impact onssimulacra2.c(fork-local).Reproducer
Test plan
meson test -C build-mem --suite=fast— 49/49 OK under ASanmeson test -C build-mem— 63/63 OK under ASancambi,ssimulacra2,motionextractors — no leak report, EXIT 0pre-commit run --files <touched>— all gates greenbash scripts/ci/assertion-density.sh ...— PASSbash scripts/ci/check-copyright.sh— PASSAvoided overlap with
PR #297 (
init_blur_array), PR #289 (CUDA PTX unload), PR #290 (HIP ssimulacra2), PR #293 (SYCL init), PR #296 (feature_extractor leaks), PR #317 (gpu_picture_pool UAF), PR #352 (sanitizer pass). All cited clusters in this PR are distinct sites.🤖 Generated with Claude Code