Uploaded image for project: 'Couchbase C client library libcouchbase'
  1. Couchbase C client library libcouchbase
  2. CCBC-65

Memory leak in libcouchbase_create / libcouchbase_destroy (POC and patch included)

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 1.0.2
    • Fix Version/s: 1.0.4
    • Component/s: library
    • Security Level: Public
    • Labels:
      None
    • Environment:
      Linux Centos

      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.

      1. leak.c
        0.9 kB
        James
      2. memory_leak.patch
        1 kB
        James
      # Subject Project Status CR V
      For Gerrit Dashboard: &For+CCBC-65=message:CCBC-65

        Activity

        jamesoc James created issue -
        avsej Sergey Avseyev made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 1.0.4 [ 10327 ]
        Resolution Fixed [ 1 ]
        avsej Sergey Avseyev made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        brett19 Brett Lawson made changes -
        Workflow jira [ 17122 ] Couchbase SDK Workflow [ 43728 ]

          People

          • Assignee:
            avsej Sergey Avseyev
            Reporter:
            jamesoc James
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 4h
              4h
              Remaining:
              Remaining Estimate - 4h
              4h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Gerrit Reviews

                There are no open Gerrit changes