Pointer free early bug

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: BSON
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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.

            Assignee:
            Andrew Morrow (Inactive)
            Reporter:
            vrqq
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: