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

FeatureCompatibilityVersion static functions can access uninitialized optional

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Replication
    • Fully Compatible
    • ALL
    • Repl 2024-02-05, Repl 2024-02-19
    • 18

      FeatureCompatibilityVersion::validateSetFeatureCompatibilityVersionRequest calls value() here on a boost::optional<BSONObj> it obtains from FeatureCompatibilityVersion::findFeatureCompatibilityVersionDocument.

      findFeatureCompatabilityVersionDocument will return an uninitialized optional here if the underlying StorageInterface->findById fails for any reason (for example, if the opCtx is killed due to repl state change).

      If we call value() on the optional when it is uninitialized, it will throw a boost::bad_optional_access exception, which is not caught in the server and will ultimately result in a server crash. We should check if the optional is none and propagate up a correct/useful error to the top layer.

      FeatureCompatibilityVersion::updateFeatureCompatibilityVersionDocument seems to have the same problem here

            Assignee:
            huayu.ouyang@mongodb.com Huayu Ouyang
            Reporter:
            george.wangensteen@mongodb.com George Wangensteen
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: