Skip to content

fix(runtime): prevent leaks in two-pass timestamp inference - #3448

Merged
LauraGPT merged 1 commit into
modelscope:mainfrom
wangxiuwen:fix/tpass-buffer-lifetime
Aug 3, 2026
Merged

fix(runtime): prevent leaks in two-pass timestamp inference#3448
LauraGPT merged 1 commit into
modelscope:mainfrom
wangxiuwen:fix/tpass-buffer-lifetime

Conversation

@wangxiuwen

Copy link
Copy Markdown
Contributor

What does this PR do?

Fix two ownership leaks in the timestamp pass of FunTpassInferBuffer:

  • Replace the per-iteration heap allocations for the one-element input pointer and length arrays with stack arrays.
  • Release the fetched AudioFrame before the empty-result early continue.

Why is this needed?

The input arrays were allocated with new[] on every timestamp-pass iteration and were never released. In addition, when SplitStr returned no fields, control skipped the existing frame cleanup at the end of the loop.

Both leaks accumulate while processing two-pass streaming audio. The stack arrays have the same lifetime required by the synchronous Forward call and require no ownership management.

Validation

  • git diff --check
  • Verified both Forward overloads still receive the same one-element pointer and length arrays.
  • Verified every loop exit now releases the fetched frame.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@LauraGPT LauraGPT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validated the exact PR head together with #3448, #3449, and #3450 on current main in an isolated worktree.

  • Full ONNX Runtime C++ build completed with FFmpeg enabled and AddressSanitizer instrumentation; all library, runtime binary, and OpenFST targets built successfully.
  • An ASAN harness verified AudioFrame copy construction and assignment own independent sample buffers and preserve metadata.
  • The same harness exercised the invalid-buffer FFmpeg cleanup path 1,000 times with leak detection enabled.
  • No AddressSanitizer error or leak was reported.

The three patches touch separate ownership problems and merge cleanly as a set.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants