[netcdfgroup] valgrind errors for very simple Netcdf4-program

Hi all,

I boiled my problems down to a very, very simple netcdf-program:

#include <stdio.h>
#include <netcdf.h>
int main(void)
{
        int val = 13;
        int ncid, dimid, varid;

        printf("%s\n",nc_inq_libvers());

        nc_create("nc4_test.nc", NC_NETCDF4, &ncid);

        nc_def_dim(ncid,"val",  1,&dimid);
        nc_def_var(ncid,"val",  NC_INT, 1,&dimid,&varid);
        nc_enddef(ncid);
        
        nc_put_var_int (ncid,varid,&val);

        nc_close(ncid);
        return 0;
}

compiles fine with:
 gcc -o nc4_test nc4_test.c -lnetcdf -lhdf5_hl -lhdf5

./nc4_test says:
 4.0 of Aug  1 2008 16:01:13 $

ncdump nc4_test.nc gives the output as expected:

netcdf nc4_test {
dimensions:
        val = 1 ;
variables:
        int val(val) ;
data:

 val = 13 ;
}

Now the problem is valgrind ./nc4_test: 

==22817== Memcheck, a memory error detector.
==22817== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al.
==22817== Using LibVEX rev 1575, a library for dynamic binary translation.
==22817== Copyright (C) 2004-2005, and GNU GPL'd, by OpenWorks LLP.
==22817== Using valgrind-3.1.1, a dynamic binary instrumentation framework.
==22817== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al.
==22817== For more details, rerun with: -v
==22817== 
4.0 of Aug  1 2008 16:01:13 $
==22817== Conditional jump or move depends on uninitialised value(s)
==22817==    at 0x4DA73DA: H5P_set (in /usr/local/lib64/libhdf5.so.5.0.1)
==22817==    by 0x4D94E13: H5Pset_fill_value 
(in /usr/local/lib64/libhdf5.so.5.0.1)
==22817==    by 0x40FDCF: nc4_rec_write_metadata (nc4hdf.c:1012)
==22817==    by 0x408EA8: sync_netcdf4_file (nc4file.c:655)
==22817==    by 0x403B69: main (in /data/home/oa027/src/nlc/nc4_test)
==22817== 
==22817== Conditional jump or move depends on uninitialised value(s)
==22817==    at 0x4DA73DA: H5P_set (in /usr/local/lib64/libhdf5.so.5.0.1)
==22817==    by 0x4D91258: H5P_dcrt_copy 
(in /usr/local/lib64/libhdf5.so.5.0.1)
==22817==    by 0x4DAA75C: H5P_copy_plist 
(in /usr/local/lib64/libhdf5.so.5.0.1)
==22817==    by 0x4CC9456: H5D_new (in /usr/local/lib64/libhdf5.so.5.0.1)
==22817==    by 0x4CC9782: H5D_create (in /usr/local/lib64/libhdf5.so.5.0.1)
==22817==    by 0x4CD65B0: H5O_dset_create 
(in /usr/local/lib64/libhdf5.so.5.0.1)
==22817==    by 0x4D62327: H5O_obj_create 
(in /usr/local/lib64/libhdf5.so.5.0.1)
==22817==    by 0x4D5DE8F: H5L_link_cb (in /usr/local/lib64/libhdf5.so.5.0.1)
==22817==    by 0x4D31C53: H5G_traverse_real 
(in /usr/local/lib64/libhdf5.so.5.0.1)
==22817==    by 0x4D3245B: H5G_traverse (in /usr/local/lib64/libhdf5.so.5.0.1)
==22817==    by 0x4D58199: H5L_create_real 
(in /usr/local/lib64/libhdf5.so.5.0.1)
==22817==    by 0x4D5826B: H5L_link_object 
(in /usr/local/lib64/libhdf5.so.5.0.1)
==22817== 
==22817== ERROR SUMMARY: 32 errors from 2 contexts (suppressed: 3 from 1)
==22817== malloc/free: in use at exit: 0 bytes in 0 blocks.
==22817== malloc/free: 2,067 allocs, 2,067 frees, 786,394 bytes allocated.
==22817== For counts of detected errors, rerun with: -v
==22817== All heap blocks were freed -- no leaks are possible.

Did I do something wrong or is this a serious problem, and how can I solve it? 
Although it seems to work, I don't want to proceed with valgrind errors.

Thanks a lot
Natalie


  • 2008 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: