[SERVER-1372] NULL check for auto_ptr<DBClientConnection> is missing Created: 07/Jul/10  Updated: 12/Jul/16  Resolved: 15/Jul/10

Status: Closed
Project: Core Server
Component/s: Internal Client
Affects Version/s: None
Fix Version/s: 1.5.5

Type: Bug Priority: Major - P3
Reporter: Kazuki Ohta Assignee: Mathias Stearn
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux


Attachments: Text File mongodb-client-dbclientcursor-null-check-2.patch     Text File mongodb-client-dbclientcursor-null-check.patch    
Operating System: ALL
Participants:

 Description   

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



 Comments   
Comment by Mathias Stearn [ 15/Jul/10 ]

conn->more() will now assert if conn is NULL. Same for conn->hasResultFlag()

Comment by auto [ 15/Jul/10 ]

Author:

{'login': 'RedBeard0531', 'name': 'Mathias Stearn', 'email': 'mathias@10gen.com'}

Message: Assert if DBClientCursor is NULL SERVER-1372
http://github.com/mongodb/mongo/commit/c5d33d557eeec1f9b1c48564e2a455cb7b227358

Comment by Kazuki Ohta [ 07/Jul/10 ]

previous patch wrongly includes the server-side codes.

Comment by Kazuki Ohta [ 07/Jul/10 ]

Or returning empty DBClientCursor will be an another good solution. This doesn't need any modification outside DBClientCursor.

Generated at Thu Feb 08 02:56:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.