Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-1372

NULL check for auto_ptr<DBClientConnection> is missing

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.5.5
    • Affects Version/s: None
    • Component/s: Internal Client
    • Labels:
      None
    • Environment:
      Linux
    • ALL

      When I'm testing ReplicaPair for automatic failover, my C++ client program got SEGV.

      I setup two mongodb instances, and killed + restarted two servers randomly.

      I used PairedDbConnection, and call GridFS::removeFIle().

      By the stacktrace, found that client.query() returns null auto_ptr if server is dead. But GridFS code doesn't check this situation.

      void GridFS::removeFile( const string& fileName ){
      auto_ptr<DBClientCursor> files = _client.query( _filesNS , BSON( "filename" << fileName ) );
      while (files->more())

      { ... }

      }

      I changed the code as follows, and confirmed that the problem was fixed.

      while (files.get() && files->more())

      { .... }

      The attached patch added the null check for DBClientCursor in the client code. There are some places which have the same problem.

      The server program has the same problem in many places, but this patch is only for the client.

      Could you commit this patch, and please fix the server-side also? I'm really happy if this problem is backported to the stable version.

      Thanks in advance
      Kazuki

            Assignee:
            mathias@mongodb.com Mathias Stearn
            Reporter:
            kzk_mover Kazuki Ohta
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: