Bug #2872

udata being leaked after DBClose

Added by Mark Miller 5 months ago. Updated 5 months ago.

Status:New Start:07/26/2017
Priority:Normal Due date:
Assigned to:- % Done:

0%

Category:-
Target version:-
Likelihood:3 - Occasional OS:All
Severity:2 - Minor Irritation Support Group:Any
Silo Found in Version:4.8

Description

Recently, I got complaints that there were massive memory leaks in my implementation of load balancing (a pretty understandable complaint), so I am now going back to fix things. I got most of them, but there is one small memory leak in silo that I am not sure about. In valgrind, we see that the memory leak occurs in silo_hdf5.c 4927, in the function db_hdf5_process_file_options. The line is: if (NULL == (udata = (db_hdf5_H5LT_file_image_ud_t *)malloc(sizeof(db_hdf5_H5LT_file_image_ud_t)))).  In my ALE3D code, I have astd::vector<char> which contains some bytes ( an in-memory hdf5 file ) that were sent from one processor to another. I am taking those bytes and making them into a silo file again as follows:
 
      int file_len = (int)fileBytes.size();
      char *fileBytesChar = (char *)malloc(file_len);
      std::copy(fileBytes.begin(), fileBytes.end(), fileBytesChar);
      int fic_vfd = DB_H5VFD_FIC;
      DBAddOption(core_opts, DBOPT_H5_VFD, &fic_vfd);
      DBAddOption(core_opts, DBOPT_H5_FIC_SIZE, &file_len);
      DBAddOption(core_opts, DBOPT_H5_FIC_BUF, fileBytesChar);
    core_opts_id = DBRegisterFileOptionsSet(core_opts);
 
      /* Ok, now have Silo open this buffer */
      retval = DBOpen(name, DB_HDF5_OPTS(core_opts_id), DB_READ);  // MEMORY BUG WHEN THIS IS CALLED, IN db_hdf5_process_file_options .
      if (retval == nullptr) {
         Fail("MakeVirDB",
              "Failure to make virtual file from vector of bytes") ;
      }
 

Also available in: Atom PDF