Skip to content

fix: Preserve gRPC trace context length - #8988

Closed
amarrtech wants to merge 1 commit into
triton-inference-server:mainfrom
amarrtech:codex/fix-grpc-trace-context-length
Closed

amarrtech wants to merge 1 commit into
triton-inference-server:mainfrom
amarrtech:codex/fix-grpc-trace-context-length

Conversation

@amarrtech

Copy link
Copy Markdown

What does the PR do?

Constructs the OpenTelemetry carrier value from gRPC metadata with both its pointer and explicit length. This prevents the nostd::string_view constructor from using strlen on grpc::string_ref::data() and reading beyond the metadata value, which can make valid 55-byte traceparent headers fail parsing.

Checklist

  • I have read the contribution guidelines.
  • I have signed the Contributor License Agreement.
  • PR title reflects the change and is of format <commit_type>: <Title>.
  • Changes are described in the pull request.
  • Related issues are referenced.
  • Populated the GitHub labels field.
  • Added a test plan and verified the available tests pass.
  • Verified that the PR passes existing CI.
  • I ran pre-commit run --all locally; see Caveats.
  • Verified copyright is correct on all changed files.
  • Added succinct git squash message before merging: fix: preserve gRPC trace context length.
  • All template sections are filled out.

Commit Type:

  • fix

Related PRs:

None.

Where should the reviewer start?

src/grpc/infer_handler.h, in GrpcServerCarrier::Get.

Test plan:

  • uvx pre-commit run --files src/grpc/infer_handler.h — passed, including clang-format, codespell, secret scan, merge-conflict checks, and license validation.
  • git diff --check — passed.
  • Compiled a C++ constructor-semantics regression harness using a 55-byte traceparent followed by a non-null byte. The pointer-only view reported length 56; the pointer-plus-size view reported 55.

Caveats:

This host does not have CMake, a built Triton server image, or the GPU test stack needed for qa/L0_trace. A repository-wide pre-commit run was attempted, but current main fails its all-files flake8 pass on existing unrelated files; the changed header passes the configured hooks in isolation.

Background

A grpc::string_ref is not required to be null-terminated. Passing only data() selects the C-string constructor and derives the length with strlen, so trace context acceptance depends on the adjacent byte in memory.

Related Issues:

Assisted-by: OpenAI Codex
Signed-off-by: Amrinder Randhawa <272048731+amarrtech@users.noreply.github.com>
@amarrtech

Copy link
Copy Markdown
Author

Closing this duplicate because #8987 opened first with the same one-line fix and verification for #8984.

@amarrtech amarrtech closed this Sep 29, 2026
@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Fixes trace context propagation in gRPC handler.

The PR appears safe to merge.

Summary

The PR changes GrpcServerCarrier::Get to preserve the explicit length of a gRPC metadata value when returning an OpenTelemetry string view, avoiding a length calculation from a potentially non-null-terminated pointer.

Reviews (1) · Last reviewed commit: "fix: preserve gRPC trace context length"

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant