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

Memory Leak found with LSan in ma_net.c

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 3.0.6
    • 3.1.10
    • None
    • None
    • CentOS7 docker image.

    Description

      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);
      #endif
      

      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)

      Attachments

        Activity

          People

            georg Georg Richter
            AnimeshSoni-ea Animesh Soni
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

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