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

invalid use of DBClientBase object with DBClientCursor destructor that is tracked by v8

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None

      I opened this originally under Core Server with Server-11741. I think this is where it belongs?

      In engine_v8.h, the following (global?) variables are used to track objects referenced by v8:
      ObjTracker<BSONHolder> bsonHolderTracker;
      ObjTracker<DBClientWithCommands> dbClientWithCommandsTracker;
      ObjTracker<DBClientBase> dbClientBaseTracker;
      ObjTracker<DBClientCursor> dbClientCursorTracker;
      .
      Objects tracked by these are deleted by v8 with the callback deleteOnCollect.

      The problem is that the dbClientCursorTracker may have references to DBClientCursors that reference an instance of a DBClientBase that is also tracked by v8. If v8 decides to delete the DBClientBase before an associated DBClientCursor, then the DBClientCursor will have a pointer to a DBClientBase that has already been deleted. The destructor will then crash on the following code:
      _client->sayPiggyBack( m );

      So, suppose we have a DBClientBase* foo, and DBClientCursor* bar, both of which are tracked by v8, and that bar->_client == foo. If v8 destroys foo before bar, then the client may crash when destroying bar, due to bar's now bad reference to foo.

            Assignee:
            Unassigned Unassigned
            Reporter:
            zardosht Zardosht Kasheff
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: