Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-1184

Prevent misuse of client temporaries

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 3.3.0-rc0
    • None
    • Documentation
    • None

    Description

      (Original title: "find/cursor documentation doesn't warn about client lifetime")

      From https://groups.google.com/forum/#!topic/mongodb-user/girvbR21AzM:

      auto c = pool->acquire()->database()[collection].find({});
      // loop c
      

      pool->acquire() returns an unique_ptr, and cursor object c rely on this unique_ptr, before c destroy, unique_ptr need stay.
      This is dangerous, however user may never find this bug until they release into production env.
      Maybe add an assert to check this, let it crash early.

      Attachments

        Activity

          People

            Unassigned Unassigned
            david.golden@mongodb.com David Golden
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: