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

_mongoc_cursor_run_command() may leak cursor->reader

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.3.1
    • Affects Version/s: 1.3.0
    • Component/s: libmongoc
    • None

      Comparing _mongoc_cursor_run_command()'s call to bson_reader_new_from_data() with other instances through libmongoc, I noticed that it doesn't check and free a previously allocated reader. I believe this is related to the following memory leaked spotted in several PHPC test failures:

      ==10816== 160 bytes in 1 blocks are definitely lost in loss record 38 of 94
      ==10816==    at 0x4C2BBA0: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==10816==    by 0x911A2F: _emalloc (zend_alloc.c:2427)
      ==10816==    by 0x911D91: _safe_emalloc (zend_alloc.c:2583)
      ==10816==    by 0x911EE4: _ecalloc (zend_alloc.c:2610)
      ==10816==    by 0x96F98F4: php_phongo_calloc (php_phongo.c:2030)
      ==10816==    by 0x96A4E4D: bson_malloc0 (bson-memory.c:103)
      ==10816==    by 0x96A654C: bson_reader_new_from_data (bson-reader.c:541)
      ==10816==    by 0x96C0898: _mongoc_cursor_run_command (mongoc-cursor.c:559)
      ==10816==    by 0x96C3A1D: _mongoc_cursor_cursorid_refresh_from_command (mongoc-cursor-cursorid.c:72)
      ==10816==    by 0x96C3E1A: _mongoc_cursor_cursorid_prime (mongoc-cursor-cursorid.c:136)
      ==10816==    by 0x96C4259: _mongoc_cursor_cursorid_next (mongoc-cursor-cursorid.c:224)
      ==10816==    by 0x96C1323: _mongoc_cursor_find_command (mongoc-cursor.c:775)
      

            Assignee:
            jmikola@mongodb.com Jeremy Mikola
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: