Annotate BSONElement and BSONObj APIs with [[clang::lifetimebound]]

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Server Programmability
    • Programmability 2025-06-09, Programmability 2025-06-23, Programmability 2025-07-07
    • None
    • 3
    • TBD
    • None
    • None
    • None
    • None
    • None
    • None

      BSONElement instances are always views into a subset of a buffer containing a BSON document which is owned by a different object, and BSONObj instances are sometimes views of the entire documents to which they refer. We currently lack any compile-time protections against temporal memory misuses of these types due to referencing underlying buffers after their owning objects have been destroyed. Investigate solving these temporal memory misuses by annotating the BSONElement and BSONObj APIs with the [[clang::lifetimebound]] attribute. If we are able to solve some or all such temporal memory misuses, commit these annotations; otherwise, document the attempts made and why they didn't work to inform potential future uses of the attribute.

            Assignee:
            Billy Donahue
            Reporter:
            James Bronsted
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: