Skip to content

Commit

Permalink
re: github issues
Browse files Browse the repository at this point in the history
    #1168
    #1163
    #1162

This PR partially fixes memory leaks in the netcdf-c library,
in the ncdump utility, and in some test cases.

The netcdf-c library now runs memory clean with the assumption
that the --disable-utilities option is used. The primary remaining
problem is ncgen. Once that is fixed, I believe the netcdf-c library
will run memory clean with no limitations.

Notes
-----------
1. Memory checking was performed using gcc -fsanitize=address.
   Valgrind-based testing has yet to be performed.
2. The pnetcdf, hdf4, and examples code has not been tested.

Misc. Non-leak changes
1. Make tst_diskless2 only run when netcdf4 is enabled (issue 1162)
2. Fix CmakeLists.txt to turn off logging if ENABLE_NETCDF_4 is OFF
3. Isolated all my debug scripts into a single top-level directory
   called debug
4. Fix some USE_NETCDF4 dependencies in nc_test and nc_test4 Makefile.am
  • Loading branch information
DennisHeimbigner committed Oct 30, 2018
1 parent 8d5e66e commit 23f9ef8
Show file tree
Hide file tree
Showing 92 changed files with 979 additions and 410 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,9 @@ ENDIF()

# Option Logging, only valid for netcdf4.
OPTION(ENABLE_LOGGING "Enable Logging." OFF)
IF(NOT ENABLE_NETCDF_4)
SET(ENABLE_LOGGING OFF)
ENDIF()
IF(ENABLE_LOGGING)
ADD_DEFINITIONS(-DLOGGING)
ADD_DEFINITIONS(-DENABLE_SET_LOG_LEVEL)
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ AC_DEFINE_UNQUOTED([NCIO_MINBLOCKSIZE], [$NCIO_MINBLOCKSIZE], [min blocksize for
# Find valgrind, if available, and add targets for it.
AX_VALGRIND_DFLT([sgcheck], [off])
AX_VALGRIND_CHECK
AM_CONDITIONAL(ENABLE_VALGRIND, [test "x$VALGRIND_ENABLED" = xyes])

###
# Doxygen and doxygen-related options.
Expand Down
7 changes: 4 additions & 3 deletions dap4_test/baseline/test_atomic_array.5.nc.d4d
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
netcdf test_atomic_array.5.nc {
types:
ubyte(*) _bytestring ;
opaque(16) opaque16_t ;
dimensions:
_Anonymous1 = 1 ;
_Anonymous2 = 2 ;
variables:
ubyte vu8(_Anonymous1, _Anonymous2) ;
double vd(_Anonymous1) ;
string vs(_Anonymous1, _Anonymous1) ;
_bytestring vo(_Anonymous1, _Anonymous1) ;
opaque16_t vo(_Anonymous1, _Anonymous1) ;

// global attributes:
string :_dap4.ce = "/vu8[1][0:2:2];/vd[1];/vs[1][0];/vo[0][1]" ;
Expand All @@ -24,5 +24,6 @@ data:
"Καλημέα" ;

vo =
{171, 205, 239, 0, 0, 0, 0, 0} ;
0XABCDEF00000000000000000000000000 ;

}
6 changes: 3 additions & 3 deletions dap4_test/baseline/test_atomic_array.nc.d4d
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ types:
Stratocumulus = 3, Cumulus = 4, Altostratus = 5, Nimbostratus = 6,
Altocumulus = 7, Cirrostratus = 8, Cirrocumulus = 9, Cirrus = 10,
Missing = 127} ;
ubyte(*) _bytestring ;
opaque(16) opaque16_t ;
dimensions:
d1 = 1 ;
d2 = 2 ;
Expand All @@ -18,7 +18,7 @@ variables:
double vd(d2) ;
char vc(d2) ;
string vs(d2, d2) ;
_bytestring vo(d1, d2) ;
opaque16_t vo(d1, d2) ;
cloud_class_t primary_cloud(d5) ;
cloud_class_t primary_cloud:_FillValue = Missing ;

Expand All @@ -45,7 +45,7 @@ data:
"Καλημέα", "abc" ;

vo =
{1, 35, 69, 103, 137, 171, 205, 239}, {171, 205, 239, 0, 0, 0, 0, 0} ;
0X0123456789ABCDEF0000000000000000, 0XABCDEF00000000000000000000000000 ;

primary_cloud = Clear, Stratus, Clear, Cumulonimbus, _ ;
}
7 changes: 3 additions & 4 deletions dap4_test/baseline/test_atomic_array.syn.d4d
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ types:
Stratocumulus = 3, Cumulus = 4, Altostratus = 5, Nimbostratus = 6,
Altocumulus = 7, Cirrostratus = 8, Cirrocumulus = 9, Cirrus = 10,
Missing = 127} ;
ubyte(*) _bytestring ;
opaque(16) opaque16_t ;
dimensions:
d1 = 1 ;
d2 = 2 ;
Expand All @@ -18,7 +18,7 @@ variables:
double vd(d2) ;
char vc(d2) ;
string vs(d2, d2) ;
_bytestring vo(d1, d2) ;
opaque16_t vo(d1, d2) ;
cloud_class_t primary_cloud(d5) ;
cloud_class_t primary_cloud:_FillValue = Missing ;

Expand Down Expand Up @@ -46,8 +46,7 @@ data:

vo =

{162, 23, 122, 167, 40, 124, 4, 250, 139, 181, 123, 205, 247, 110, 200, 15},
{52, 250, 71, 42, 169, 64, 77, 213, 67, 20, 60, 173, 237, 48, 58, 117} ;
0XA2177AA7287C04FA8BB57BCDF76EC80F, 0X34FA472AA9404DD543143CADED303A75 ;

primary_cloud = Stratus, Cirrocumulus, Nimbostratus, Cirrostratus,
Stratocumulus ;
Expand Down
4 changes: 2 additions & 2 deletions dap4_test/baseline/test_atomic_array.syn.d4m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ types:
Stratocumulus = 3, Cumulus = 4, Altostratus = 5, Nimbostratus = 6,
Altocumulus = 7, Cirrostratus = 8, Cirrocumulus = 9, Cirrus = 10,
Missing = 127} ;
ubyte(*) _bytestring ;
opaque(16) opaque16_t ;
dimensions:
d1 = 1 ;
d2 = 2 ;
Expand All @@ -18,7 +18,7 @@ variables:
double vd(d2) ;
char vc(d2) ;
string vs(d2, d2) ;
_bytestring vo(d1, d2) ;
opaque16_t vo(d1, d2) ;
cloud_class_t primary_cloud(d5) ;
cloud_class_t primary_cloud:_FillValue = Missing ;

Expand Down
3 changes: 1 addition & 2 deletions dap4_test/baseline/test_atomic_array.syn.d4p
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<EnumConst name="Cirrus" value="10"/>
<EnumConst name="Missing" value="127"/>
</Enumeration>
<Opaque name="_bytestring"/>
</Types>
<Variables>
<UInt8 name="vu8">
Expand All @@ -50,7 +49,7 @@
<Dim name="/d2"/>
<Dim name="/d2"/>
</String>
<Opaque name="vo" type="/_bytestring">
<Opaque name="vo" type="/opaque16_t">
<Dim name="/d1"/>
<Dim name="/d2"/>
</Opaque>
Expand Down
6 changes: 3 additions & 3 deletions dap4_test/baseline/test_atomic_types.nc.d4d
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ types:
Stratocumulus = 3, Cumulus = 4, Altostratus = 5, Nimbostratus = 6,
Altocumulus = 7, Cirrostratus = 8, Cirrocumulus = 9, Cirrus = 10,
Missing = 127} ;
ubyte(*) _bytestring ;
opaque(16) opaque16_t ;
variables:
byte v8 ;
ubyte vu8 ;
Expand All @@ -18,7 +18,7 @@ variables:
double vd ;
char vc ;
string vs ;
_bytestring vo ;
opaque16_t vo ;
cloud_class_t primary_cloud ;
cloud_class_t primary_cloud:_FillValue = Missing ;
cloud_class_t secondary_cloud ;
Expand Down Expand Up @@ -52,7 +52,7 @@ data:

vs = "hello\tworld" ;

vo = {1, 35, 69, 103, 137, 171, 205, 239} ;
vo = 0X0123456789ABCDEF0000000000000000 ;

primary_cloud = Stratus ;

Expand Down
7 changes: 3 additions & 4 deletions dap4_test/baseline/test_atomic_types.syn.d4d
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ types:
Stratocumulus = 3, Cumulus = 4, Altostratus = 5, Nimbostratus = 6,
Altocumulus = 7, Cirrostratus = 8, Cirrocumulus = 9, Cirrus = 10,
Missing = 127} ;
ubyte(*) _bytestring ;
opaque(16) opaque16_t ;
variables:
byte v8 ;
ubyte vu8 ;
Expand All @@ -18,7 +18,7 @@ variables:
double vd ;
char vc ;
string vs ;
_bytestring vo ;
opaque16_t vo ;
cloud_class_t primary_cloud ;
cloud_class_t primary_cloud:_FillValue = Missing ;
cloud_class_t secondary_cloud ;
Expand Down Expand Up @@ -52,8 +52,7 @@ data:

vs = "O,L?c8A%V" ;

vo =
{70, 241, 105, 239, 35, 203, 175, 155, 31, 235, 217, 158, 78, 22, 206, 201} ;
vo = 0X46F169EF23CBAF9B1FEBD99E4E16CEC9 ;

primary_cloud = Altocumulus ;

Expand Down
4 changes: 2 additions & 2 deletions dap4_test/baseline/test_atomic_types.syn.d4m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ types:
Stratocumulus = 3, Cumulus = 4, Altostratus = 5, Nimbostratus = 6,
Altocumulus = 7, Cirrostratus = 8, Cirrocumulus = 9, Cirrus = 10,
Missing = 127} ;
ubyte(*) _bytestring ;
opaque(16) opaque16_t ;
variables:
byte v8 ;
ubyte vu8 ;
Expand All @@ -18,7 +18,7 @@ variables:
double vd ;
char vc ;
string vs ;
_bytestring vo ;
opaque16_t vo ;
cloud_class_t primary_cloud ;
cloud_class_t primary_cloud:_FillValue = Missing ;
cloud_class_t secondary_cloud ;
Expand Down
3 changes: 1 addition & 2 deletions dap4_test/baseline/test_atomic_types.syn.d4p
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<EnumConst name="Cirrus" value="10"/>
<EnumConst name="Missing" value="127"/>
</Enumeration>
<Opaque name="_bytestring"/>
</Types>
<Variables>
<Int8 name="v8"/>
Expand All @@ -34,7 +33,7 @@
<Float64 name="vd"/>
<Char name="vc"/>
<String name="vs"/>
<Opaque name="vo" type="/_bytestring"/>
<Opaque name="vo" type="/opaque16_t"/>
<Enum name="primary_cloud" enum="/cloud_class_t">
<Attribute name="_FillValue" type="/cloud_class_t">
<Value value="Missing"/>
Expand Down
6 changes: 3 additions & 3 deletions dap4_test/baseline/test_opaque.nc.d4d
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
netcdf test_opaque.nc {
types:
ubyte(*) _bytestring ;
opaque(16) opaque16_t ;
variables:
_bytestring vo1 ;
opaque16_t vo1 ;

// global attributes:
:_DAP4_Little_Endian = 1UB ;
data:

vo1 = {1, 35, 69, 103, 137, 171, 205, 239} ;
vo1 = 0X0123456789ABCDEF0000000000000000 ;
}
7 changes: 3 additions & 4 deletions dap4_test/baseline/test_opaque_array.7.nc.d4d
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
netcdf test_opaque_array.7.nc {
types:
ubyte(*) _bytestring ;
opaque(16) opaque16_t ;
dimensions:
_Anonymous1 = 1 ;
_Anonymous2 = 2 ;
variables:
_bytestring vo2(_Anonymous1, _Anonymous2) ;
opaque16_t vo2(_Anonymous1, _Anonymous2) ;

// global attributes:
string :_dap4.ce = "/vo2[1][0:1]" ;
:_DAP4_Little_Endian = 1UB ;
data:

vo2 =
{254, 220, 186, 152, 118, 84, 50, 16},
{254, 220, 186, 153, 153, 153, 153, 153} ;
0XFEDCBA98765432100000000000000000, 0XFEDCBA99999999990000000000000000 ;
}
9 changes: 4 additions & 5 deletions dap4_test/baseline/test_opaque_array.nc.d4d
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
netcdf test_opaque_array.nc {
types:
ubyte(*) _bytestring ;
opaque(16) opaque16_t ;
dimensions:
d2 = 2 ;
variables:
_bytestring vo2(d2, d2) ;
opaque16_t vo2(d2, d2) ;

// global attributes:
:_DAP4_Little_Endian = 1UB ;
data:

vo2 =
{1, 35, 69, 103, 137, 171, 205, 239}, {171, 205, 239, 0, 0, 0, 0, 0},
{254, 220, 186, 152, 118, 84, 50, 16},
{254, 220, 186, 153, 153, 153, 153, 153} ;
0X0123456789ABCDEF0000000000000000, 0XABCDEF00000000000000000000000000,
0XFEDCBA98765432100000000000000000, 0XFEDCBA99999999990000000000000000 ;
}
6 changes: 3 additions & 3 deletions dap4_test/baselineraw/test_atomic_array.5.nc.dmp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
netcdf test_atomic_array.5 {
types:
ubyte(*) _bytestring ;
opaque(16) opaque16_t ;
dimensions:
_Anonymous1 = 1 ;
_Anonymous2 = 2 ;
variables:
ubyte vu8(_Anonymous1, _Anonymous2) ;
double vd(_Anonymous1) ;
string vs(_Anonymous1, _Anonymous1) ;
_bytestring vo(_Anonymous1, _Anonymous1) ;
opaque16_t vo(_Anonymous1, _Anonymous1) ;

// global attributes:
string :_dap4.ce = "/vu8[1][0:2:2];/vd[1];/vs[1][0];/vo[0][1]" ;
Expand All @@ -24,5 +24,5 @@ data:
"Καλημέα" ;

vo =
{171, 205, 239, 0, 0, 0, 0, 0} ;
0XABCDEF00000000000000000000000000 ;
}
6 changes: 3 additions & 3 deletions dap4_test/baselineraw/test_atomic_array.nc.dmp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ types:
Stratocumulus = 3, Cumulus = 4, Altostratus = 5, Nimbostratus = 6,
Altocumulus = 7, Cirrostratus = 8, Cirrocumulus = 9, Cirrus = 10,
Missing = 127} ;
ubyte(*) _bytestring ;
opaque(16) opaque16_t ;
dimensions:
d1 = 1 ;
d2 = 2 ;
Expand All @@ -18,7 +18,7 @@ variables:
double vd(d2) ;
char vc(d2) ;
string vs(d2, d2) ;
_bytestring vo(d1, d2) ;
opaque16_t vo(d1, d2) ;
cloud_class_t primary_cloud(d5) ;
cloud_class_t primary_cloud:_FillValue = Missing ;

Expand All @@ -45,7 +45,7 @@ data:
"Καλημέα", "abc" ;

vo =
{1, 35, 69, 103, 137, 171, 205, 239}, {171, 205, 239, 0, 0, 0, 0, 0} ;
0X0123456789ABCDEF0000000000000000, 0XABCDEF00000000000000000000000000 ;

primary_cloud = Clear, Stratus, Clear, Cumulonimbus, _ ;
}
8 changes: 3 additions & 5 deletions dap4_test/baselineraw/test_atomic_array.syn.dmp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ types:
Stratocumulus = 3, Cumulus = 4, Altostratus = 5, Nimbostratus = 6,
Altocumulus = 7, Cirrostratus = 8, Cirrocumulus = 9, Cirrus = 10,
Missing = 127} ;
ubyte(*) _bytestring ;
opaque(16) opaque16_t ;
dimensions:
d1 = 1 ;
d2 = 2 ;
Expand All @@ -18,7 +18,7 @@ variables:
double vd(d2) ;
char vc(d2) ;
string vs(d2, d2) ;
_bytestring vo(d1, d2) ;
opaque16_t vo(d1, d2) ;
cloud_class_t primary_cloud(d5) ;
cloud_class_t primary_cloud:_FillValue = Missing ;

Expand All @@ -45,9 +45,7 @@ data:
"4a/q%n9;5Y", "{fIl?T\"\\A[" ;

vo =

{162, 23, 122, 167, 40, 124, 4, 250, 139, 181, 123, 205, 247, 110, 200, 15},
{52, 250, 71, 42, 169, 64, 77, 213, 67, 20, 60, 173, 237, 48, 58, 117} ;
0XA2177AA7287C04FA8BB57BCDF76EC80F, 0X34FA472AA9404DD543143CADED303A75 ;

primary_cloud = Stratus, Cirrocumulus, Nimbostratus, Cirrostratus,
Stratocumulus ;
Expand Down
6 changes: 3 additions & 3 deletions dap4_test/baselineraw/test_atomic_types.nc.dmp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ types:
Stratocumulus = 3, Cumulus = 4, Altostratus = 5, Nimbostratus = 6,
Altocumulus = 7, Cirrostratus = 8, Cirrocumulus = 9, Cirrus = 10,
Missing = 127} ;
ubyte(*) _bytestring ;
opaque(16) opaque16_t ;
variables:
byte v8 ;
ubyte vu8 ;
Expand All @@ -18,7 +18,7 @@ variables:
double vd ;
char vc ;
string vs ;
_bytestring vo ;
opaque16_t vo ;
cloud_class_t primary_cloud ;
cloud_class_t primary_cloud:_FillValue = Missing ;
cloud_class_t secondary_cloud ;
Expand Down Expand Up @@ -52,7 +52,7 @@ data:

vs = "hello\tworld" ;

vo = {1, 35, 69, 103, 137, 171, 205, 239} ;
vo = 0X0123456789ABCDEF0000000000000000 ;

primary_cloud = Stratus ;

Expand Down
Loading

0 comments on commit 23f9ef8

Please sign in to comment.