Skip to content

Remove stale GenAI LSan suppressions and fix tool-call parsing UAF - #1323

Open
bmehta001 wants to merge 2 commits into
mainfrom
chore/remove-stale-genai-lsan-suppressions
Open

bmehta001 wants to merge 2 commits into
mainfrom
chore/remove-stale-genai-lsan-suppressions

Conversation

@bmehta001

Copy link
Copy Markdown
Contributor

Summary

  • Remove the OgaCreateStringArrayFromStrings and OrtxTensorResultGetAt LSan suppressions. They were fixed by Fix memory leaks onnxruntime-genai#2153 and Cleanup TensorObject created by OrtxTensorResultGetAt onnxruntime-genai#2168, and the SDK now consumes GenAI 0.19.0.
  • Keep Generators::State::Run. Fix nemotron leaks onnxruntime-genai#2169 was merged, but the leak (~2–4 MB per process) still reproduces with GenAI 0.19.0 in StreamingAudioFixture/Nemotron audio tests. The comment now says so.
  • Fix a real stack-use-after-scope that the full sanitizer run exposed. In tool_call_utils.cc, const auto& [name, arguments] = *call.items().begin(); binds to a temporary iteration_proxy_value, and name (via key()) is read after it is destroyed. This aborted foundry_local_tests partway through under ASan.

Validation

Full scripts/run_sanitizer_tests.py --skip-build --config Debug on Linux (WSL), ASan + UBSan + LSan, ORT 1.31.0 / GenAI 0.19.0, with real models (FOUNDRY_TEST_DATA_DIR):

  • foundry_local_tests: 2777/2785 passed. sdk_integration_tests: 164/164 passed. This includes VisionFixture and ResponsesVisionIntegrationTest (image-processor paths) and StreamingAudioFixture.
  • AddressSanitizer errors: 0. LeakSanitizer leaks: 0.
  • Removing State::Run too produced 2 leak reports rooted in Generators::State::Run, so it stays.
  • 6 tests skipped because they are env-gated (Parakeet, exported non-generative packages, qualified Qwen package).

Pre-existing issues on main, unrelated to this change:

  • ApiBackendTest.ModelHandleDispatchesToHostedAdapterWithoutNativeModel fails in Debug because FL_THROW appends a stack trace, so ends_with("host connection was lost") is false.
  • IpcChannelTest.DescriptorExhaustionRecoversAndRemainsInterruptibleByClose gets one UBSan "invalid vptr" report in its death-test child. The test exhausts RLIMIT_NOFILE, and UBSan's vptr check uses a pipe to probe memory accessibility, so this looks like a sanitizer false positive under fd exhaustion.

bmehta001 and others added 2 commits November 10, 2026 18:23
`*call.items().begin()` dereferences a temporary iteration_proxy_value,
and the structured binding's `name` calls key() on it after the full
expression ends. ASan reports stack-use-after-scope in
ToolCallStreamAccumulatorTest.RepairedCustomShapesPreserveDuplicateInputSource,
which aborts the sanitizer unit run. Read the key and value through an
lvalue object iterator, whose references point into the JSON object.

Files changed:
- sdk_v2/cpp/src/inferencing/generative/toolcalling/tool_call_utils.cc

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 458edacb-429b-4169-99fb-c2241f5113d4
The OgaCreateStringArrayFromStrings and OrtxTensorResultGetAt leaks were
fixed by microsoft/onnxruntime-genai#2153 and #2168, and the SDK now
consumes GenAI 0.19.0. The full sanitizer suite, including the real-model
vision integration tests that drive those image-processor paths, reports
no leaks without them. Keeping stale suppressions would hide a regression.

Generators::State::Run stays suppressed: its leak still reproduces with
GenAI 0.19.0 in StreamingAudioFixture despite #2169, so the comment now
records that.

Files changed:
- sdk_v2/cpp/test/asan/lsan.supp

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 458edacb-429b-4169-99fb-c2241f5113d4
Copilot AI balanced review requested due to automatic review settings November 11, 2026 00:46
@vercel

vercel Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
foundry-local Ready Ready Preview Nov 11, 2026 12:46am UTC

Request Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are recorded for the tool-call lifetime fix and leak-suppression updates.

No open issues 🎉

What changed in this PR

Fixes a lifetime bug in C++ tool-call parsing and updates leak suppressions to reflect GenAI 0.19.0 behavior.

Changes:

  • Replaces temporary-backed structured bindings with a JSON iterator to prevent stack-use-after-scope.
  • Removes two stale leak suppressions while retaining and documenting the still-reproducing Generators::State::Run leak.
File Description
sdk_v2/​cpp/​test/​asan/​lsan.supp Removes resolved leak suppressions and clarifies why the remaining GenAI suppression is needed.
sdk_v2/​cpp/​src/​inferencing/​generative/​toolcalling/​tool_call_utils.cc Uses iterator key/value access to safely parse singleton tool calls.

Review effort: Balanced

This branch was successfully deployed

1 active deployment
Preview — 219cbd46 Deployed Nov 11, 2026 by vercel[bot]
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