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

Possible leak in _mongoc_uri_assign_read_prefs_mode()

    • Type: Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: uri
    • None

      Summary

      I observed the following leak in Valgrind in a test that does nothing more than construct a MongoDB\Driver\Manager instance. This effectively creates one single-threaded mongoc_client_t from a URI struct.

      ==1100655== 436 bytes in 1 blocks are still reachable in loss record 5 of 9
      ==1100655==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==1100655==    by 0x4013E4D: malloc (rtld-malloc.h:56)
      ==1100655==    by 0x4013E4D: allocate_dtv_entry (dl-tls.c:684)
      ==1100655==    by 0x4013E4D: allocate_and_init (dl-tls.c:709)
      ==1100655==    by 0x4013E4D: tls_get_addr_tail (dl-tls.c:907)
      ==1100655==    by 0x401826B: __tls_get_addr (tls_get_addr.S:55)
      ==1100655==    by 0x8B1D983: _mongoc_uri_assign_read_prefs_mode (mongoc-uri.c:1770)
      ==1100655==    by 0x8B21802: mongoc_uri_new_with_error (mongoc-uri.c:1957)
      ==1100655==    by 0x8B982EB: php_phongo_make_uri (phongo_client.c:100)
      ==1100655==    by 0x8B9D1E4: phongo_manager_init (phongo_client.c:1487)
      ==1100655==    by 0x8BD039E: zim_MongoDB_Driver_Manager___construct (Manager.c:277)
      ==1100655==    by 0x8B710F: ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER (zend_vm_execute.h:1842)
      ==1100655==    by 0x92E741: execute_ex (zend_vm_execute.h:56052)
      ==1100655==    by 0x933EDF: zend_execute (zend_vm_execute.h:60384)
      ==1100655==    by 0x87314B: zend_execute_scripts (zend.c:1780)
      ==1100655== 
      

      See: https://github.com/mongodb/mongo-c-driver/blob/3e8a24311c21917420fd7fd2b00637deb4b168ce/src/libmongoc/src/mongoc/mongoc-uri.c#L1770

      Environment

      libmongoc 1.24-dev: https://github.com/mongodb/mongo-c-driver/commit/3e8a24311c

      Ubuntu 22.04.2 LTS

      gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04)

            Assignee:
            kevin.albertson@mongodb.com Kevin Albertson
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: