[CDRIVER-446] Memory leak in mongoc_client_command_simple() Created: 19/Oct/14 Updated: 19/Oct/16 Resolved: 05/Nov/14 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | None |
| Affects Version/s: | 1.0.2 |
| Fix Version/s: | 1.1.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Jerome Lebel | Assignee: | Mira Carey |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
when I call mongoc_database_get_collection_info() a new bson is created: the bson correct. But, this bson is sent to mongoc_database_command_simple() and then to mongoc_client_command_simple() The issue is this bson is sent to bson_init() : so the flags of this bson changes from BSON_FLAG_INLINE to BSON_FLAG_INLINE | BSON_FLAG_STATIC So later when bson_destroy() is called, the buffer is not freed() I think bson_reinit() should be called instead. But I'm not sure. I'm not even sure if we need to call something on this bson. |
| Comments |
| Comment by Jerome Lebel [ 06/Nov/14 ] |
|
My idea was to say all bson from reply as to be initialized. That we can either do: bson *command_reply = bson_new(); for me this should not be allowed: only this should exist: But well that's my personal opinion, and as long as I don't have memory leaks, I'm happy. Thanks! |
| Comment by Jerome Lebel [ 06/Nov/14 ] |
|
Sorry, I made a mistake between branches. I tested a branch that doesn't have your fix yet. I tried the master, I don't see the leak anymore! Thanks. |
| Comment by Mira Carey [ 06/Nov/14 ] |
|
I'm not sure where you're seeing that leak. I've been making sure to run the test suite through valgrind and confirmed the leak you were seeing, fixed it, and then observed that valgrind no longer reported the leak. If there's a use case I've missed I'd be happy to add it to the test suite and reopen this. I'm sorry if you're not thrilled with the way I fixed this, but I had a couple of constraints I tried to work within:
I apologize if I'm missing something obvious, but I don't see how database_get_collection_info leaks at this point in master |
| Comment by Jerome Lebel [ 05/Nov/14 ] |
|
There is still a memory leak in mongoc_client_command_simple() when using mongoc_database_get_collection_info() |
| Comment by Jerome Lebel [ 04/Nov/14 ] |
|
I don't really understand why it is fixed. bson_init() is still called, therefore the flags are still changed. Anyone who doesn't know this issue will create a memory leak. For me the consequences are fixed, but not the origin of this bug. |
| Comment by Githook User [ 04/Nov/14 ] |
|
Author: {u'username': u'hanumantmk', u'name': u'Jason Carey (hanumantmk)', u'email': u'jcarey@argv.me'}Message: fix a leak in mongoc_client_command_simple(). Fix some other random leaks while we're at it Closes #110 |