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

IDL generates use-after-move initialization for nss and nssOrUUID parameters

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible
    • ALL
    • Server Serverless 2023-04-17

      The IDL compiler generates initializer statements for the _dbName member using variables that have already been moved into local members. Here are a few examples:

      build/debug/mongo/db/modules/enterprise/src/search/search_index_commands_gen.cpp
      519:CreateSearchIndexesCommand::CreateSearchIndexesCommand(const NamespaceString nss, boost::optional<SerializationContext> serializationContext) : _serializationContext(serializationContext.value_or(SerializationContext::stateCommandRequest())), _nss(std::move(nss)), _dbName(nss.dbName()), _hasIndexes(false), _hasDbName(true) {
      
      build/debug/mongo/idl/unittest_gen.cpp:BasicConcatenateWithDbOrUUIDCommand::BasicConcatenateWithDbOrUUIDCommand(const NamespaceStringOrUUID nssOrUUID, std::int32_t field1, std::string field2, boost::optional<SerializationContext> serializationContext) : _serializationContext(serializationContext.value_or(SerializationContext::stateCommandRequest())), _nssOrUUID(nssOrUUID), _field1(std::move(field1)), _field2(std::move(field2)), _dbName(nssOrUUID.uuid() ? nssOrUUID.dbName().value() : nssOrUUID.nss()->dbName()), _hasField1(true), _hasField2(true), _hasDbName(true) {
      

            Assignee:
            matt.broadstone@mongodb.com Matt Broadstone
            Reporter:
            matt.broadstone@mongodb.com Matt Broadstone
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: