ExportXMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Catalog and Routing
    • CAR Team 2026-11-09
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Coverity issue SERVER-138382, pointed to the logic around managing in-flight OpCtx values as a potential use-after-free case. The analysis turned out to be a false positive and I don't see any risks in the current logic, but the current implementation is fragile and future refactors could break the assumptions currently in place.

      Here are a few possible strategies:

      • CancelableOperationContext
        • This is seemingly not viable, or any sort of cancellation-token-style approach, as a hard markKilled is needed, especially in a shutdown sequence when the executor may already be shutting down and can't deliver the cancellation signal.
      • OperationContextGroup
        • This appears to be a good candidate, as it wraps the OpCtx management logic and has simple makeOperationContext/interrupt operations. This would eliminate the need to manually manage raw OpCtx pointers.
      • ScopeGuard placement
        • Currently the OpCtx pointer is stored in the inflightMap and then the ScopeGuard is registered afterward, leaving a window where an exception could leave a dangling raw pointer in the map (the issue Coverity highlighted). If the ScopeGuard block was before the pointer store, no such window would exist.

      Further brainstorming is needed to pursue these options (and any others that come up), but a refactor would greatly improve maintainability and readability of this logic going forward.

            Assignee:
            Laura Mestres Torres
            Reporter:
            Jordan Glassley
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: