Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-908

Memory leak in dump API

    • Type: Icon: Task Task
    • Resolution: Done
    • WT2.2
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      The dump API currently has a memory leak:

      Direct leak of 675 byte(s) in 1 object(s) allocated from:
          #0 0x42dab4 in calloc (/home/alexg/work/wiredtiger/build_posix/.libs/lt-wt+0x42dab4)
          WT-1 0x7ffff79c21ea in __wt_calloc /home/alexg/work/wiredtiger/build_posix/../src/os_posix/os_alloc.c:38
          WT-2 0x7ffff79c56ae in __wt_strndup /home/alexg/work/wiredtiger/build_posix/../src/os_posix/os_alloc.c:183
          WT-3 0x7ffff79c5ded in __wt_strdup /home/alexg/work/wiredtiger/build_posix/../src/os_posix/os_alloc.c:203
          WT-4 0x7ffff79b0b2a in __wt_metadata_search /home/alexg/work/wiredtiger/build_posix/../src/meta/meta_table.c:182
          WT-5 0x7ffff79ab64e in __wt_ext_metadata_search /home/alexg/work/wiredtiger/build_posix/../src/meta/meta_ext.c:62
          WT-6 0x4478f1 in dump_config /home/alexg/work/wiredtiger/build_posix/../src/utilities/util_dump.c:191
          WT-7 0x445a72 in util_dump /home/alexg/work/wiredtiger/build_posix/../src/utilities/util_dump.c:94
          WT-8 0x45ed95 in main /home/alexg/work/wiredtiger/build_posix/../src/utilities/util_main.c:181
      

      It's not trivial to fix this leak, since we are calling:

      Unable to find source-code formatter for language: int. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
       (*metadata_search)(WT_EXTENSION_API *wt_api,
                  WT_SESSION *session, const char *key, const char **valuep);

      and the memory leaked is that returned in valuep. I think we should remove the const from the API, and document that the user is responsible for freeing thre returned string. I've opened an issue, since this is an API change and I could be missing a subtlety.

      I made a naive fix for this here:
      https://github.com/wiredtiger/wiredtiger/commit/8293fba35f450d1d1e03d7d306e139c1c90c9115

      That fix fails testing due to the constness of the value variable (which I could cast away, but I don't think that is the right solution).

            Assignee:
            alexander.gorrod@mongodb.com Alexander Gorrod
            Reporter:
            alexander.gorrod@mongodb.com Alexander Gorrod
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: