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

Coverity analysis defect 114295: Bad bit shift operation

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Index Maintenance
    • Labels:
    • ALL
    • Execution Team 2020-12-14

      Bad bit shift operation

      The operation may have an undefined behavior or yield an unexpected result. A bit shift operation has a shift amount which is too large or has a negative value.
      /src/mongo/db/storage/key_string.cpp:693: BAD_SHIFT 114295 Function call "mongo::countLeadingZeros64(integerPart << 1)" may return 64.
      /src/mongo/db/storage/key_string.cpp:693: BAD_SHIFT 114295 Assigning: "fractionalBytes" = "mongo::countLeadingZeros64(integerPart << 1) / 8". The value of "fractionalBytes" is now 8.
      /src/mongo/db/storage/key_string.cpp:707: BAD_SHIFT 114295 In expression "integerPart + 1UL << fractionalBytes * 8UL", left shifting by more than 63 bits has undefined behavior. The shift amount, "fractionalBytes * 8UL", is 64.

            Assignee:
            gregory.noma@mongodb.com Gregory Noma
            Reporter:
            xgen-internal-coverity Coverity Collector User
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: