Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-100971

Fix dangling pointer to OperationContext in PipelineOptimizationTest

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.1.0-rc0
    • Affects Version/s: 8.1.0-rc0
    • Component/s: Aggregation Framework
    • None
    • Catalog and Routing
    • Fully Compatible
    • CAR Team 2025-03-03
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      pipeline_test.cpp contains a assertPipelineOptimizesTo function which constructs and returns a Pipeline instance.

       

      To construct it, assertPipelineOptimizesTo creates a local-scoped OperationContext which is associated to the ExpressionContext for that Pipeline. But since the OperationContext is local-scoped, it is destroyed when the function returns, which means that the Pipeline returned by the function contains a dangling pointer to the destroyed OperationContext.

       

      Currently this is harmless, however as part of SPM-4048 we intend to use that OperationContext to check feature flags, so we need to ensure that the lifetime of the Pipeline is contained within that of the OperationContext.

            Assignee:
            joan.bruguera-mico@mongodb.com Joan Bruguera Micó
            Reporter:
            joan.bruguera-mico@mongodb.com Joan Bruguera Micó
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              None
              None
              None
              None