Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-5791

Memory Leak in SASL at shutdown

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 1.27.5
    • Component/s: Authentication
    • None
    • C Drivers
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Summary

      LeakSanitizer is showing a SASL leak at shutdown.

      ==29830==ERROR: LeakSanitizer: detected memory leaks
      
      Direct leak of 192 byte(s) in 1 object(s) allocated from:
      #0 0x60b40975e86f in malloc (/home/user/folder/proc/build/bin/proc+0x10b386f)
      #1 0x7c5880f10a07 ()
      #2 0x7c5880f1118e ()
      #3 0x7c58829b1529 in sasl_client_add_plugin (/lib/x86_64-linux-gnu/libsasl2.so.2+0xb529)
      #4 0x7c58829b7a20 (/lib/x86_64-linux-gnu/libsasl2.so.2+0x11a20)
      #5 0x7c58829b38ae in sasl_client_init (/lib/x86_64-linux-gnu/libsasl2.so.2+0xd8ae)
      #6 0x7c5882bd07a7 in _mongoc_do_init (/usr/local/lib/libmongoc-1.0.so.0+0x6a7a7)
      #7 0x7c5882bd0a0a in mongoc_init (/usr/local/lib/libmongoc-1.0.so.0+0x6aa0a)
      

      There are other objects in sasl_client_add_plugin that are reported as leaked as well.

      Source

      Community Forum

      Environment

      mongo-c-driver-1.27.5, compiled and run on Ubuntu 24.04.1 LTS

      How to Reproduce

      #include <mongoc/mongoc.h>
      
      int main(int argc, char** argv) {
              mongoc_init();
              mongoc_cleanup();
              return 0;
      }
      
      g++ -g -O0 -static-libasan -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -I/usr/local/include/libbson-1.0 -I/usr/local/include/libmongoc-1.0 main.cpp -Wl,-s -L/usr/local/lib/libmongoc-1.0 -lmongoc-1.0 -o main
      
      ./main
      

      Leaks printed here.

            Assignee:
            Unassigned Unassigned
            Reporter:
            rishabh.bisht@mongodb.com Rishabh Bisht
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: