[CCBC-65] Memory leak in libcouchbase_create / libcouchbase_destroy (POC and patch included) Created: 15/May/12 Updated: 13/Nov/12 Resolved: 15/May/12 |
|
| Status: | Closed |
| Project: | Couchbase C client library libcouchbase |
| Component/s: | library |
| Affects Version/s: | 1.0.2 |
| Fix Version/s: | 1.0.4 |
| Security Level: | Public |
| Type: | Bug | Priority: | Critical |
| Reporter: | James | Assignee: | Sergey Avseyev |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | 4h | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | 4h | ||
| Environment: | Linux Centos | ||
| Attachments: |
|
| Description |
|
When the client calls libcouchbase_create and then later calls libcouchbase_destroy, some memory is leaked. For a client with many threads that open and close couchbase sessions, this will lead to memory exhaustion. The leak is caused by the use of strdup() in setup_boostrap_hosts(). These duplicated strings are not free'd in libcouchbase_destroy. The leak can be seen by using valgrind.
I have attached a proof of concept, and a patch with a proposed fix. I have only tested on 1.0.2, but other versions may be affected. |
| Comments |
| Comment by Sergey Avseyev [ 15/May/12 ] |
| Good job. Thanks. Your patch imported into review system http://review.couchbase.org/16032 |
| Comment by Sergey Avseyev [ 15/May/12 ] |
| Merged. Will be accessible in next release or now on the github https://github.com/couchbase/libcouchbase |