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

Pointer free early bug

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • None
    • BSON
    • None

    Description

      See this example below:
      bsoncxx::document::view getfilter ()
      {
      bsoncxx::builder::basic::document filter{};
      filter.append( bsoncxx::builder::basic::kvp("p_test", "abcabc") );
      return filter.view();
      }
      main()

      { bsoncxx::document::view filter=getfilter(); //error }

      //the filter's construction contain " *_data " pointer. but this pointer's destination memory will free when getfilter() function returned.
      so I got "EXC_Bad_ACCESS" error.

      This bug occasional occur, I suppose it depends c++ recycling the memory zone with "_data" pointer.

      Another source of evidence:
      auto filter = th->getfilter();
      auto cursor = result.find(filter);
      when I run directly, it told me "EXC_Bad_ACCESS".
      But when I run into debug mode and "STEP BY STEP" before that statements, it seems normally, and got a right result.

      My program is single threaded.

      Attachments

        Activity

          People

            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            vrqq vrqq
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: