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

Invariant failure - isVersionInitialized()

    • Server Security
    • Fully Compatible
    • Security 2023-04-03, Security 2023-04-17

      I've got a C# .NET application (driver 2.19.0) and I'm querying a DB using IAggregateFluent with a match, a lookup, and a projection. This is the pretty-print of the query - it's nothing terribly fancy:

      [
        {
          "$match": {
            "Timestamp": {
              "$gte": "ISODate(2023-02-20T14:40:00Z)"
            }
          }
        },
        {
          "$lookup": {
            "from": "RemoteCommandResults",
            "localField": "_id",
            "foreignField": "CommandId",
            "as": "Results"
          }
        },
        {
          "$project": {
            "_id": "$_id",
            "Command": "$Command",
            "CommandType": "$CommandType",
            "Timestamp": "$Timestamp",
            "ClientIpAddress": "$ClientIpAddress",
            "Location": "$Location",
            "SubmittedByUser": "$SubmittedByUser",
            "CompletedEndpoints": {
              "$map": {
                "input": {
                  "$filter": {
                    "input": "$Results",
                    "as": "r",
                    "cond": {
                      "$ne": [
                        "$$r.WhenCompleted",
                        null
                      ]
                    }
                  }
                },
                "as": "r",
                "in": "$$r.EndpointId"
              }
            },
            "PendingEndpoints": {
              "$map": {
                "input": {
                  "$filter": {
                    "input": "$Results",
                    "as": "r",
                    "cond": {
                      "$not": {
                        "$ne": [
                          "$$r.WhenCompleted",
                          null
                        ]
                      }
                    }
                  }
                },
                "as": "r",
                "in": "$$r.EndpointId"
              }
            }
          }
        }
      ] 

      I'm using CSFLE with mongo_crypt_v1.dll and running on Windows.

      If I don't enable encryption, i.e., leave the AutoEncryptionOptions out of the MongoClientSettings, everything works as expected.

      If encryption is enabled however, either libmongocrypt.dll or mongo_crypt_v1.dll prints an assertion failure to the console window and aborts the application:

      {"t":{"$date":"2023-03-09T21:04:56.738Z"},"s":"F",  "c":"ASSERT",   "id":23079,   "ctx":"thread13","msg":"Invariant failure","attr":{"expr":"isVersionInitialized()","file":"Z:\\data\\mci\\badd693c2380d3476d7367abd345c3b9\\src\\src\\mongo/db/server_options.h","line":156}}
      {"t":{"$date":"2023-03-09T21:04:56.738Z"},"s":"F",  "c":"ASSERT",   "id":23080,   "ctx":"thread13","msg":"\n\n***aborting after invariant() failure\n\n"} 

      The query seems to be well formed, as evidenced by the fact that it works when the encryption libraries aren't in use, so I suspect there may be a bug in the encryption libraries and how they handle aggregation pipelines.

            Assignee:
            shreyas.kalyan@mongodb.com Shreyas Kalyan
            Reporter:
            eric.rosenquist@forescout.com Eric Rosenquist
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: