[CDRIVER-4626] Possible leak in _mongoc_uri_assign_read_prefs_mode() Created: 26/Apr/23  Updated: 14/Jun/23  Resolved: 14/Jun/23

Status: Closed
Project: C Driver
Component/s: uri
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Unknown
Reporter: Jeremy Mikola Assignee: Kevin Albertson
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to CDRIVER-4503 Add a BSON Handling EDSL Closed

 Description   

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)



 Comments   
Comment by Kevin Albertson [ 14/Jun/23 ]

I suggest suppressing this leak. As of https://github.com/mongodb/mongo-c-driver/pull/1177, the C driver no longer uses Valgrind for leak detection.

Generated at Wed Feb 07 21:21:27 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.