Skip to content

[Bug]: get_critical_path MCP tool produces invalid uint64 offset values due to unsigned underflow #9519

Description

@vjkumar2756

What happened?

As an LLM agent or Jaeger user invoking the get_critical_path MCP tool,
I want accurate relative time offsets (StartOffsetUs and EndOffsetUs) for critical-path segments,
so that latency analysis and timeline visualization reflect valid trace timings.

Description:
When querying the critical path of a trace using the get_critical_path MCP handler, StartOffsetUs and EndOffsetUs can underflow Go's uint64 subtraction if a critical path section timestamp (section.SectionStart or section.SectionEnd) is less than the calculated traceStartTime. This causes relative offset fields to wrap around to invalid values such as 18446744073709551615 (over 18 quintillion microseconds).

Steps to reproduce

  1. Run Jaeger with jaegerquery MCP tools enabled.
  2. Execute get_critical_path on a trace where span sanitization or clock skew causes a critical path section's SectionStart timestamp to precede the calculated traceStartTime.
  3. Inspect the returned JSON payload in the segments array.
    4.Observe start_offset_us or end_offset_us returning 18446744073709551615.

Expected behavior

StartOffsetUs and EndOffsetUs should represent valid non-negative microsecond offsets relative to traceStartTime. If a section start/end timestamp is less than traceStartTime, the relative offset should clamp to 0 rather than underflowing uint64.

Relevant log output

{
  "trace_id": "00000000000000000000000000000001",
  "total_duration_us": 100000,
  "critical_path_duration_us": 1000,
  "segments": [
    {
      "span_id": "0000000000000001",
      "service_name": "test-service",
      "span_name": "child-operation",
      "self_time_us": 1000,
      "start_offset_us": 18446744073709551615,
      "end_offset_us": 18446744073709551615
    }
  ]
}

Screenshot

No response

Additional context

The issue occurs in buildOutput() inside cmd/jaeger/internal/extension/jaegerquery/internal/mcptools/internal/handlers/get_critical_path.go:

go
StartOffsetUs: section.SectionStart - traceStartTime,
EndOffsetUs: section.SectionEnd - traceStartTime,
Because SectionStart and traceStartTime are uint64, when section.SectionStart < traceStartTime, Go's subtraction wraps around to near $2^{64}-1$.

Jaeger backend version

v2.x

SDK

No response

Pipeline

No response

Stogage backend

Any (Memory, Elasticsearch, Cassandra, BoltDB)

Operating system

Linux

Deployment model

Go binary / Docker / Kubernetes

Deployment configs

Activity

  1. DsThakurRawat commented on Sep 10, 2026

    @DsThakurRawat
    Contributor

    heads up that #9339 is already open on this output. traceStartTime uses 0 as "unset" at line 143, so a span that genuinely starts at 0 is skipped, the trace start lands after that section, and the subtractions at lines 174-175 wrap. #9433 has fixed that sentinel since aug 29 and is still unreviewed. worth a look before two patches land on the same lines, since clamping the subtraction hides that case rather than fixing it.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions