mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-02-17 16:50:18 +08:00
This is a follow up to PR https://github.com/Unidata/netcdf-c/pull/1173 Sorry that it is so big, but leak suppression can be complex. This PR fixes all remaining memory leaks -- as determined by -fsanitize=address, and with the exceptions noted below. Unfortunately. there remains a significant leak that I cannot solve. It involves vlens, and it is unclear if the leak is occurring in the netcdf-c library or the HDF5 library. I have added a check_PROGRAM to the ncdump directory to show the problem. The program is called tst_vlen_demo.c To exercise it, build the netcdf library with -fsanitize=address enabled. Then go into ncdump and do a "make clean check". This should build tst_vlen_demo without actually executing it. Then do the command "./tst_vlen_demo" to see the output of the memory checker. Note the the lost malloc is deep in the HDF5 library (in H5Tvlen.c). I am temporarily working around this error in the following way. 1. I modified several test scripts to not execute known vlen tests that fail as described above. 2. Added an environment variable called NC_VLEN_NOTEST. If set, then those specific tests are suppressed. This should mean that the --disable-utilities option to ./configure should not need to be set to get a memory leak clean build. This should allow for detection of any new leaks. Note: I used an environment variable rather than a ./configure option to control the vlen tests. This is because it is temporary (I hope) and because it is a bit tricky for shell scripts to access ./configure options. Finally, as before, this only been tested with netcdf-4 and hdf5 support.
59 lines
1.7 KiB
C
59 lines
1.7 KiB
C
/*********************************************************************
|
|
* Copyright 2009, UCAR/Unidata
|
|
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
|
*********************************************************************/
|
|
|
|
#ifndef NCOFFSETS_H
|
|
#define NCOFFSETS_H 1
|
|
|
|
/* Define indices for every primitive C type */
|
|
/* NAT => NOT-A-TYPE*/
|
|
#define NC_NATINDEX 0
|
|
#define NC_CHARINDEX 1
|
|
#define NC_UCHARINDEX 2
|
|
#define NC_SHORTINDEX 3
|
|
#define NC_USHORTINDEX 4
|
|
#define NC_INTINDEX 5
|
|
#define NC_UINTINDEX 6
|
|
#define NC_LONGINDEX 7
|
|
#define NC_ULONGINDEX 8
|
|
#define NC_LONGLONGINDEX 9
|
|
#define NC_ULONGLONGINDEX 10
|
|
#define NC_FLOATINDEX 11
|
|
#define NC_DOUBLEINDEX 12
|
|
#define NC_PTRINDEX 13
|
|
#define NC_NCVLENINDEX 14
|
|
|
|
#define NC_NCTYPES 15
|
|
|
|
typedef struct NCalignment {
|
|
char* type_name;
|
|
size_t alignment;
|
|
} NCalignment;
|
|
|
|
typedef NCalignment NCtypealignvec;
|
|
|
|
/* Capture in struct and in a vector*/
|
|
typedef struct NCtypealignset {
|
|
NCalignment charalign; /* char*/
|
|
NCalignment ucharalign; /* unsigned char*/
|
|
NCalignment shortalign; /* short*/
|
|
NCalignment ushortalign; /* unsigned short*/
|
|
NCalignment intalign; /* int*/
|
|
NCalignment uintalign; /* unsigned int*/
|
|
NCalignment longalign; /* long*/
|
|
NCalignment ulongalign; /* unsigned long*/
|
|
NCalignment longlongalign; /* long long*/
|
|
NCalignment ulonglongalign; /* unsigned long long*/
|
|
NCalignment floatalign; /* float*/
|
|
NCalignment doublealign; /* double*/
|
|
NCalignment ptralign; /* void**/
|
|
NCalignment ncvlenalign; /* nc_vlen_t*/
|
|
} NCtypealignset;
|
|
|
|
size_t NC_class_alignment(int ncclass);
|
|
void NC_compute_alignments(void);
|
|
int NC_alignments_computed;
|
|
|
|
#endif /*NCOFFSETS_H*/
|