Memory leak in H5TS_errstk_key_g

There seem to be a memory leak in HDF5 1.8.11 in conjunction to the H5TS_errstk_key_g thread-local variable [allocated in H5E_get_stack function in H5E.c]. The leak is only approx. 1kB large, but it still leads to "noise" in memory leak dumps that can easily hide bigger leaks. Therefore, it would be great if the leaks could be fixed for the next release.

Minimal code to reproduce:

···

---------------------------------------------
#include <hdf5.h>
#include <crtdbg.h> // for _CrtSetDbgFlag

/** Program to reproduce HDF5 memory leak. */
int main (int argc, char* argv[]) {
#ifdef _WIN32
     // activate dumping of memory leaks upon program termination
     // http://msdn.microsoft.com/en-us/library/e5ewb1h3.aspx
     _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif

     // create dummy HDF5 file
     hid_t fid = H5Fcreate("delme.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
     herr_t err = H5Fclose(fid);
     if (err < 0)
         return -1;

     return 0;
}
---------------------------------------------

Upon termination, the following is returned:
Detected memory leaks!
Dumping objects ->
{1880} normal block at 0x005B92B0, 928 bytes long.
  Data: < > 00 00 00 00 CD CD CD CD CD CD CD CD CD CD CD CD
{1879} normal block at 0x005B9268, 8 bytes long.
  Data: <x ^^ > 78 F4 5E 5E 00 00 00 00
Object dump complete.

Stack trace for 1st leaked allocation:
      msvcr100d.dll!malloc(unsigned int nSize=8) Line 56 + 0x15 bytes C++
      hdf5_D.dll!H5FL_reg_init(H5FL_reg_head_t * head=0x583ef478) Line 239 + 0xa bytes C
      hdf5_D.dll!H5FL_reg_malloc(H5FL_reg_head_t * head=0x583ef478) Line 380 + 0x9 bytes C
      hdf5_D.dll!H5E_get_stack() Line 370 + 0xa bytes C
      hdf5_D.dll!H5E_clear_stack(H5E_t * estack=0x00000000) Line 952 + 0x5 bytes C
      hdf5_D.dll!H5Fcreate(const char * filename=0x0041573c, unsigned int flags=2, int fcpl_id=0, int fapl_id=0) Line 1458 + 0x109 bytes C
      hdfleak.exe!main(int argc=1, char * * argv=0x00613b28) Line 20 + 0x2b bytes C++
Stack trace for 2nd leaked allocation:
      msvcr100d.dll!malloc(unsigned int nSize=928) Line 56 + 0x15 bytes C++
      hdf5_D.dll!H5FL_malloc(unsigned int mem_size=928) Line 199 + 0xc bytes C
      hdf5_D.dll!H5FL_reg_malloc(H5FL_reg_head_t * head=0x583ef478) Line 399 + 0xc bytes C
      hdf5_D.dll!H5E_get_stack() Line 370 + 0xa bytes C
      hdf5_D.dll!H5E_clear_stack(H5E_t * estack=0x00000000) Line 952 + 0x5 bytes C
      hdf5_D.dll!H5Fcreate(const char * filename=0x0041573c, unsigned int flags=2, int fcpl_id=0, int fapl_id=0) Line 1458 + 0x109 bytes C
      hdfleak.exe!main(int argc=1, char * * argv=0x00613b28) Line 20 + 0x2b bytes C++

Configuration:
* Windows 7 SP1 (x64)
* Visual Studio 2010 SP1
* HDF5 1.8.11 C library compiled as 32bit DLL

Thanks in advance,
Fredrik Orderud

Frederick,

Thank you for the report! It is in our issue data base now and we will investigate. For the reference, the issue id is HDFFV-8518.

Elena

···

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Elena Pourmal The HDF Group http://hdfgroup.org
1800 So. Oak St., Suite 203, Champaign IL 61820
217.531.6112
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

On Sep 8, 2013, at 8:18 AM, Fredrik Orderud wrote:

Stack trace for 1st leaked allocation:
    msvcr100d.dll!malloc(unsigned int nSize=8) Line 56 + 0x15 bytes C++
    hdf5_D.dll!H5FL_reg_init(H5FL_reg_head_t * head=0x583ef478) Line 239 + 0xa bytes C
    hdf5_D.dll!H5FL_reg_malloc(H5FL_reg_head_t * head=0x583ef478) Line 380 + 0x9 bytes C
    hdf5_D.dll!H5E_get_stack() Line 370 + 0xa bytes C
    hdf5_D.dll!H5E_clear_stack(H5E_t * estack=0x00000000) Line 952 + 0x5 bytes C
    hdf5_D.dll!H5Fcreate(const char * filename=0x0041573c, unsigned int flags=2, int fcpl_id=0, int fapl_id=0) Line 1458 + 0x109 bytes C
    hdfleak.exe!main(int argc=1, char * * argv=0x00613b28) Line 20 + 0x2b bytes C++
Stack trace for 2nd leaked allocation:
    msvcr100d.dll!malloc(unsigned int nSize=928) Line 56 + 0x15 bytes C++
    hdf5_D.dll!H5FL_malloc(unsigned int mem_size=928) Line 199 + 0xc bytes C
    hdf5_D.dll!H5FL_reg_malloc(H5FL_reg_head_t * head=0x583ef478) Line 399 + 0xc bytes C
    hdf5_D.dll!H5E_get_stack() Line 370 + 0xa bytes C
    hdf5_D.dll!H5E_clear_stack(H5E_t * estack=0x00000000) Line 952 + 0x5 bytes C
    hdf5_D.dll!H5Fcreate(const char * filename=0x0041573c, unsigned int flags=2, int fcpl_id=0, int fapl_id=0) Line 1458 + 0x109 bytes C
    hdfleak.exe!main(int argc=1, char * * argv=0x00613b28) Line 20 + 0x2b bytes C++

Configuration:
* Windows 7 SP1 (x64)
* Visual Studio 2010 SP1
* HDF5 1.8.11 C library compiled as 32bit DLL

Thanks in advance,
Fredrik Orderud

I don't see my reply. It is a second attempt.

Sorry if you get duplicates.

Elena

···

Begin forwarded message:

From: Elena Pourmal <epourmal@hdfgroup.org>
Date: September 8, 2013 4:49:55 PM CDT
To: HDF Users Discussion List <hdf-forum@lists.hdfgroup.org>
Subject: Re: [Hdf-forum] Memory leak in H5TS_errstk_key_g

Frederick,

Thank you for the report! It is in our issue data base now and we will investigate. For the reference, the issue id is HDFFV-8518.

Elena
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Elena Pourmal The HDF Group http://hdfgroup.org
1800 So. Oak St., Suite 203, Champaign IL 61820
217.531.6112
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

On Sep 8, 2013, at 8:18 AM, Fredrik Orderud wrote:

Stack trace for 1st leaked allocation:
    msvcr100d.dll!malloc(unsigned int nSize=8) Line 56 + 0x15 bytes C++
    hdf5_D.dll!H5FL_reg_init(H5FL_reg_head_t * head=0x583ef478) Line 239 + 0xa bytes C
    hdf5_D.dll!H5FL_reg_malloc(H5FL_reg_head_t * head=0x583ef478) Line 380 + 0x9 bytes C
    hdf5_D.dll!H5E_get_stack() Line 370 + 0xa bytes C
    hdf5_D.dll!H5E_clear_stack(H5E_t * estack=0x00000000) Line 952 + 0x5 bytes C
    hdf5_D.dll!H5Fcreate(const char * filename=0x0041573c, unsigned int flags=2, int fcpl_id=0, int fapl_id=0) Line 1458 + 0x109 bytes C
    hdfleak.exe!main(int argc=1, char * * argv=0x00613b28) Line 20 + 0x2b bytes C++
Stack trace for 2nd leaked allocation:
    msvcr100d.dll!malloc(unsigned int nSize=928) Line 56 + 0x15 bytes C++
    hdf5_D.dll!H5FL_malloc(unsigned int mem_size=928) Line 199 + 0xc bytes C
    hdf5_D.dll!H5FL_reg_malloc(H5FL_reg_head_t * head=0x583ef478) Line 399 + 0xc bytes C
    hdf5_D.dll!H5E_get_stack() Line 370 + 0xa bytes C
    hdf5_D.dll!H5E_clear_stack(H5E_t * estack=0x00000000) Line 952 + 0x5 bytes C
    hdf5_D.dll!H5Fcreate(const char * filename=0x0041573c, unsigned int flags=2, int fcpl_id=0, int fapl_id=0) Line 1458 + 0x109 bytes C
    hdfleak.exe!main(int argc=1, char * * argv=0x00613b28) Line 20 + 0x2b bytes C++

Configuration:
* Windows 7 SP1 (x64)
* Visual Studio 2010 SP1
* HDF5 1.8.11 C library compiled as 32bit DLL

Thanks in advance,
Fredrik Orderud

Gentle reminder:
The memory leak seem to be present also in the recent HDF5 1.8.12 release.

Best regards,
Fredrik

···

On 08.09.2013 23:49, Elena Pourmal wrote:

Frederick,

Thank you for the report! It is in our issue data base now and we will investigate. For the reference, the issue id is HDFFV-8518.

Elena
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Elena Pourmal The HDF Group http://hdfgroup.org
1800 So. Oak St., Suite 203, Champaign IL 61820
217.531.6112
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

On Sep 8, 2013, at 8:18 AM, Fredrik Orderud wrote:

Stack trace for 1st leaked allocation:
    msvcr100d.dll!malloc(unsigned int nSize=8) Line 56 + 0x15 bytes C++
    hdf5_D.dll!H5FL_reg_init(H5FL_reg_head_t * head=0x583ef478) Line 239 + 0xa bytes C
    hdf5_D.dll!H5FL_reg_malloc(H5FL_reg_head_t * head=0x583ef478) Line 380 + 0x9 bytes C
    hdf5_D.dll!H5E_get_stack() Line 370 + 0xa bytes C
    hdf5_D.dll!H5E_clear_stack(H5E_t * estack=0x00000000) Line 952 + 0x5 bytes C
    hdf5_D.dll!H5Fcreate(const char * filename=0x0041573c, unsigned int flags=2, int fcpl_id=0, int fapl_id=0) Line 1458 + 0x109 bytes C
    hdfleak.exe!main(int argc=1, char * * argv=0x00613b28) Line 20 + 0x2b bytes C++
Stack trace for 2nd leaked allocation:
    msvcr100d.dll!malloc(unsigned int nSize=928) Line 56 + 0x15 bytes C++
    hdf5_D.dll!H5FL_malloc(unsigned int mem_size=928) Line 199 + 0xc bytes C
    hdf5_D.dll!H5FL_reg_malloc(H5FL_reg_head_t * head=0x583ef478) Line 399 + 0xc bytes C
    hdf5_D.dll!H5E_get_stack() Line 370 + 0xa bytes C
    hdf5_D.dll!H5E_clear_stack(H5E_t * estack=0x00000000) Line 952 + 0x5 bytes C
    hdf5_D.dll!H5Fcreate(const char * filename=0x0041573c, unsigned int flags=2, int fcpl_id=0, int fapl_id=0) Line 1458 + 0x109 bytes C
    hdfleak.exe!main(int argc=1, char * * argv=0x00613b28) Line 20 + 0x2b bytes C++

Configuration:
* Windows 7 SP1 (x64)
* Visual Studio 2010 SP1
* HDF5 1.8.11 C library compiled as 32bit DLL

Thanks in advance,
Fredrik Orderud

Fredrik,

It is scheduled for 1.8.13. Sorry, didn't have man power to look into the issue for this release.

Elena

···

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Elena Pourmal The HDF Group http://hdfgroup.org
1800 So. Oak St., Suite 203, Champaign IL 61820
217.531.6112
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

On Nov 20, 2013, at 10:12 AM, Fredrik Orderud <fredrik@orderud.no> wrote:

Gentle reminder:
The memory leak seem to be present also in the recent HDF5 1.8.12 release.

Best regards,
Fredrik

On 08.09.2013 23:49, Elena Pourmal wrote:

Frederick,

Thank you for the report! It is in our issue data base now and we will investigate. For the reference, the issue id is HDFFV-8518.

Elena
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Elena Pourmal The HDF Group http://hdfgroup.org
1800 So. Oak St., Suite 203, Champaign IL 61820
217.531.6112
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

On Sep 8, 2013, at 8:18 AM, Fredrik Orderud wrote:

Stack trace for 1st leaked allocation:
    msvcr100d.dll!malloc(unsigned int nSize=8) Line 56 + 0x15 bytes C++
    hdf5_D.dll!H5FL_reg_init(H5FL_reg_head_t * head=0x583ef478) Line 239 + 0xa bytes C
    hdf5_D.dll!H5FL_reg_malloc(H5FL_reg_head_t * head=0x583ef478) Line 380 + 0x9 bytes C
    hdf5_D.dll!H5E_get_stack() Line 370 + 0xa bytes C
    hdf5_D.dll!H5E_clear_stack(H5E_t * estack=0x00000000) Line 952 + 0x5 bytes C
    hdf5_D.dll!H5Fcreate(const char * filename=0x0041573c, unsigned int flags=2, int fcpl_id=0, int fapl_id=0) Line 1458 + 0x109 bytes C
    hdfleak.exe!main(int argc=1, char * * argv=0x00613b28) Line 20 + 0x2b bytes C++
Stack trace for 2nd leaked allocation:
    msvcr100d.dll!malloc(unsigned int nSize=928) Line 56 + 0x15 bytes C++
    hdf5_D.dll!H5FL_malloc(unsigned int mem_size=928) Line 199 + 0xc bytes C
    hdf5_D.dll!H5FL_reg_malloc(H5FL_reg_head_t * head=0x583ef478) Line 399 + 0xc bytes C
    hdf5_D.dll!H5E_get_stack() Line 370 + 0xa bytes C
    hdf5_D.dll!H5E_clear_stack(H5E_t * estack=0x00000000) Line 952 + 0x5 bytes C
    hdf5_D.dll!H5Fcreate(const char * filename=0x0041573c, unsigned int flags=2, int fcpl_id=0, int fapl_id=0) Line 1458 + 0x109 bytes C
    hdfleak.exe!main(int argc=1, char * * argv=0x00613b28) Line 20 + 0x2b bytes C++

Configuration:
* Windows 7 SP1 (x64)
* Visual Studio 2010 SP1
* HDF5 1.8.11 C library compiled as 32bit DLL

Thanks in advance,
Fredrik Orderud

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org