Uploaded image for project: 'MariaDB Connector/C'
  1. MariaDB Connector/C
  2. CONC-497

Memory Leak found with LSan in ma_net.c



    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Incomplete
    • 3.0.6, 3.1.10
    • N/A
    • None
    • None
    • Centos 7 docker image


      I filed a ticket for this: https://jira.mariadb.org/browse/CONC-495
      but they closed it without answering my question.

      Can someone please answer my question regarding how the leak was fixed? And what triggers the leak?

      Georg Richter added a comment - 2 days ago
      fixed - rev. 64a421295322214c827441cf824091dc874ddc6a
      Animesh Soni added a comment - Yesterday - edited
      I just checked that the ma_net.c looks is the same for 3.0.6 and 3.1.10. Would you be able to provide context on what was triggering the leak and how was it fixed?
      Or provide me a link to another JIRA issue if there was one for the leak ?


      Hey our LSan run identified a memory leak in ma_net.c file. The memory allocated on line 311 is not freed when the function returns on line 340.

      You should add this code before returning "ma_net_real_write" on line 340:

      #ifdef HAVE_COMPRESS
        if (net->compress)
          free((char*) packet);

      This is what the LSan callstack looks like:

      Direct leak of 102 byte(s) in 6 object(s) allocated from:

      0 0x7f92a113ab78 in malloc /home/fcm/Perforce/SDK/UnixClang/dev/scripts/llvm_RELEASE_401_source/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:66
      1 0x7f92a0383b55 in ma_net_real_write /mariadb-connector-c-3.0.6-src/libmariadb/ma_net.c:311
      2 0x7f92a0383c57 in ma_net_flush /mariadb-connector-c-3.0.6-src/libmariadb/ma_net.c:166
      3 0x7f92a0383fd8 in ma_net_write_command /mariadb-connector-c-3.0.6-src/libmariadb/ma_net.c:244
      4 0x7f92a038b8ba in mthd_my_send_cmd /mariadb-connector-c-3.0.6-src/libmariadb/mariadb_lib.c:395
      5 0x7f92a0392736 in net_stmt_close /mariadb-connector-c-3.0.6-src/libmariadb/mariadb_stmt.c:1324
      6 0x7f92a0393333 in mysql_stmt_close /mariadb-connector-c-3.0.6-src/libmariadb/mariadb_stmt.c:1344
      7 0x7f92a03aa9c7 in mysql_stmt_close_start_internal /mariadb-connector-c-3.0.6-src/libmariadb/mariadb_async.c:1509
      8 0x7f92a03aeda0 in my_context_spawn /mariadb-connector-c-3.0.6-src/libmariadb/ma_context.c:201

      Can I get a better context on how we could be running into this issue? Are there any known workarounds?
      (we are avoiding making a custom version of the package)




            Richard Richard Stracke
            AnimeshSoni-ea Animesh Soni
            0 Vote for this issue
            5 Start watching this issue



              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.