Skip to content

Sporadic access violation when repeatedly evaluating IsCombedTIVTC() — possible TFM object lifetime issue #65

Description

@Deanna444

This is actually a Claude-identified bug report:

Sporadic access-violation crash (exit 0xCCCCCCCC), possibly related to per-frame TFM object construction in IsCombedTIVTC

Summary

Sporadic crashes — process exit code -858993460 (0xCCCCCCCC as unsigned 32-bit, the MSVC debug-heap "uninitialized/freed memory" fill pattern) — occur intermittently when processing long clips through scripts that call IsCombedTIVTC() as a per-frame conditional-filter expression (inside WriteFile/FrameEvaluate). The crash is non-deterministic: at least one affected file crashed on one run and completed cleanly on an immediately following re-run with no changes to script, settings, or file.

Environment

  • TIVTC 1.0.30.0 (also checked against the 1.0.28 source tree — IsCombedTIVTC.cpp and the relevant TFM.cpp code are unchanged between the two per the changelog)
  • AviSynth+ 3.7.5
  • Windows 10 x64, invoked via ffmpeg's avisynth demuxer (-f avisynth -i script.avs -f null -)
  • Source: D2VSource-decoded MPEG-2 .d2v files. Affected files span clean 3:2 telecine, native interlaced video with heavy combing, mixed/random cadence, and one genuinely progressive (non-interlaced) source — no content-type pattern identified.

Observed pattern

Crashes have occurred in two structurally different scripts whose only common element is a per-frame call to IsCombedTIVTC(cthresh=9, MI=80, chroma=false, blockx=16, blocky=16, metric=0, opt=4):

  1. A script combining TFM() + TDecimate() + IsCombedTIVTC() in one WriteFile chain, run full-length (42,000–90,000+ frames).
  2. A separate, unrelated script containing only D2VSourceSeparateFieldsFrameEvaluateIsCombedTIVTC()no TFM or TDecimate filter object at all — sampled over ~9,000 frames.

Both crashed with the same exit code, on different files, at different points in their respective runs. No other filter or code path is common to both.

Structural observation (source-reviewed; not confirmed as root cause)

Create_IsCombedTIVTC in IsCombedTIVTC.cpp constructs a brand-new TFM object on every single evaluated frame, uses it once, then destroys it:

TFM *f = new TFM(args[0].AsClip(), -1, -1, 1, 5, "", "", "", "", false, false, false, false,
    15, args[1].AsInt(9), args[2].AsInt(80), chroma, args[4].AsInt(16),
    args[5].AsInt(16), 0, 0, "", 0, 0, 12.0, 0, 0, "", false, args[6].AsInt(0), false, false, false,
    args[7].AsInt(4), env);
AVSValue IsCombedTIVTC = f->ConditionalIsCombedTIVTC(n, env);
delete f;

This is a fundamentally different usage pattern from TFM() used directly as a filter, which constructs one object per clip and reuses it via child->SetCacheHints(CACHE_GENERIC, 3). Over a 40,000–90,000-frame file, IsCombedTIVTC used this way means 40,000–90,000+ construct/allocate/destroy cycles of a full TFM object (whose constructor alone is ~860 lines) in a single run.

This pattern seems consistent with the symptoms observed:

  • Non-determinism — allocation-churn-triggered heap issues are typically harder to reproduce deterministically than logic errors.
  • The crash appearing in two otherwise-unrelated scripts whose only shared element is this construct/destroy cycle.
  • The specific 0xCCCCCCCC signature, consistent with a use-after-free, double-free, or uninitialized-read class of bug rather than a clean logic error.

I checked for the more obvious explanations first and ruled them out: no shared static/global mutable state in TFM.cpp/TFM.h that would explain a cross-thread race, and the destructor's file-write paths (output, outputC) are both empty strings in IsCombedTIVTC's construction call, so no file I/O happens in these particular objects' destructors.

I have not identified a specific defective line — I don't have a debugger or memory-sanitizer (ASan / Dr. Memory / Application Verifier) set up against this build to confirm it live. I'm reporting the pattern in case it's already a known area of concern, or worth a look by someone who can reproduce and instrument it directly.

Reproduction

I don't yet have a minimal, isolated repro script — the crash has only been observed inside a larger production pipeline, and is sporadic enough that it hasn't reproduced on an immediate identical re-run of at least one affected file. Happy to try to construct a minimal case (e.g., a tight loop of IsCombedTIVTC calls over a long synthetic clip) if that would help — let me know if that's useful before I spend the time on it.

Exit code reference

-858993460 = 0xCCCCCCCC (unsigned 32-bit) — the MSVC debug-heap fill pattern used to mark freed or uninitialized memory. Not a normal AviSynth+/ffmpeg error code.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions