To NetCDF Source Code Developers,
We are using NetCDF version 2.3.2 patch 4.
When we encounter a low memory situation (malloc's may return NULL) we
find that the NetCDF code consistently fails in the following files.
We are sending print screens of our Metaware Source Debugger. Each
page shows the Call stack, the file name, the line number which
was currently being processed, and some values of significant variables.
The first page we printed shows the actual line where the memory proctection
fault occurs. It is in file var.c at line #57. The var pointer is
0xFFFFFFFF and is trying to reference something it is pointing at.
My computer does not have 4 Gig of memory real nor virtual.
==== 1:Source
==================================================================|
43: nc_serror("NC_new_var") ;
44: return(NULL) ;
45: }
46:
47: |= 4:var ======================|
48: /* | (struct *) var = 0xffffffff |
49: * Free var |==============================|
50: */
51: void
52: NC_free_var(var)
53: NC_var *var ;
54: {
55: if(var == NULL)
56: return ;
57: NC_free_string(var->name) ;
58: NC_free_iarray(var->assoc) ;
59: if(var->shape != NULL)
60: Free(var->shape) ;
61: if(var->dsizes != NULL)
62: Free(var->dsizes) ;
63: NC_free_array(var->attrs) ;
64: Free(var) ;
65: }
66:
67:
68: /*
69: * 'compile' the shape and len of a variable
70: * return -1 on error
71: */
72: static
|-3:Call Stack ---------------------------------------------------------------|
| 0 NC_free_var(var = 0xffffffff) from array.c#348
| 1 NC_free_array(array = 0x003ee498) from cdf.c#22
| 2 NC_free_xcdf(handle = 0x003ee1d0) from cdf.c#35
| 3 NC_free_cdf(handle = 0x003ee1d0) from cdf.c#84
| 4 NC_new_cdf(name = "c:\testdata\f50.nc", mode = 1) from file.c#100
| 5 NC_open(path = "c:\testdata\f50.nc", mode = 1) from file.c#145
| 6 ncopen(path = "c:\testdata\f50.nc", mode = 1) from dsdata.c#3349
| 7 RecordOpen(filename = "f50.nc", varName = "V10", path = "c:\testdata") fr
|-----------------------------------------------------------------------------|
=== 2:Dialog =====================$var#57==================================== =|
In the second page we are in file array.c at line #348 one step up in the
stack. The variable dp points to 0xFFFFFFFF at this time. We have no
idea where this 0xFFFFFFFF comes from.
=== 1:Source ==================================================================|
335: for(dp += array->count - 1 ;
336: array->count > 0;
337: array->count--)
338: NC_free_dim(*dp-- );
339: }
340: break ;
341: case NC_VARIABLE :
342: {
343: NC_var **dp ;
344: dp = (NC_var**)array->values ;
345: for(dp += array->count - 1 ;
346: array->count > 0;
347: array->count--)
348: NC_free_var(*dp-- );
349: }
350: break ;
351: case NC_ATTRIBUTE :
352: {
353: NC_attr **dp ;
354: dp = (NC_attr**)array->values ;
355: for(dp += array->count - 1 ;
356: array->count > 0;
357: array->count--)
358: NC_free_attr(*dp-- );
359: }
360: break ;
=== 2:Dialog ====================$array#348================================== =|
|-3:dp ------------------------| |- 5:array->values -------------|
| (struct **) dp = 0x003ee524 | | (char*) ::values = 0x003ee4cc |
|------------------------------| |-------------------------------|
|- 6:*dp ----------------------| |- 4:array->count ---------------------|
| (struct *) *dp = 0xffffffff | | (unsigned long) ::count = 0x00000018 |
|------------------------------| |--------------------------------------|
->
->
->
->
|= 7:Call Stack ==============================================================|
| 0 NC_free_var(var = 0xffffffff) from array.c#348
| 1 NC_free_array(array = 0x003ee498) from cdf.c#22
| 2 NC_free_xcdf(handle = 0x003ee1d0) from cdf.c#35
| 3 NC_free_cdf(handle = 0x003ee1d0) from cdf.c#84
| 4 NC_new_cdf(name = "c:\testdata\f50.nc", mode = 1) from file.c#100
| 5 NC_open(path = "c:\testdata\f50.nc", mode = 1) from file.c#145
| 6 ncopen(path = "c:\testdata\f50.nc", mode = 1) from dsdata.c#3349
| 7 RecordOpen(filename = "f50.nc", varName = "V10", path = "c:\testdata") fr
|=============================================================================|
In the third page we are in file cdf.c at line #22 one more step up in the
stack. Window number 4 is displaying the contents of *handle->vars.
=== 1:Source ==================================================================|
9:
10:
11: /*
12: * free the stuff that xdr_cdf allocates
13: */
14: static void
15: NC_free_xcdf(handle)
16: NC *handle ;
17: {
18: if(handle == NULL)
19: return ;
20: NC_free_array(handle->dims) ;
21: NC_free_array(handle->attrs) ;
22: NC_free_array(handle->vars) ;
23: }
24:
25:
26: void
27: NC_free_cdf(handle)
28: NC *handle ;
29: {
30: if(handle == NULL)
31: return ;
32:
33: NC_free_xcdf(handle) ;
34:
=== 2:Dialog =====================$cdf#22==================================== =|
|=4:Examine ==================| |-3:handle->vars -----------------|
| [DS:3EE498] struct { | (struct *) ::vars = 0x003ee498 |
| enum type = NC_VARIABLE |---------------------------------|
| len = 0x00000060
| szof = 0x00000004
| count = 0x00000018
| values = 0x003ee4cc
| } ::vars
|=============================|
->
|- 5:Call Stack --------------------------------------------------------------|
| 0 NC_free_var(var = 0xffffffff) from array.c#348
| 1 NC_free_array(array = 0x003ee498) from cdf.c#22
| 2 NC_free_xcdf(handle = 0x003ee1d0) from cdf.c#35
| 3 NC_free_cdf(handle = 0x003ee1d0) from cdf.c#84
| 4 NC_new_cdf(name = "c:\testdata\f50.nc", mode = 1) from file.c#100
| 5 NC_open(path = "c:\testdata\f50.nc", mode = 1) from file.c#145
| 6 ncopen(path = "c:\testdata\f50.nc", mode = 1) from dsdata.c#3349
| 7 RecordOpen(filename = "f50.nc", varName = "V10", path = "c:\testdata") fr
|-----------------------------------------------------------------------------|
In the third page we are in file cdf.c at line #35 one more step up in the
stack. Window 4 is displaying *handle->xdrs. The debugger complained about
limit violation when displaying *handle->xdrs.
=== 1:Source ==================================================================|
22: NC_free_array(handle->vars) ;
23: }
24:
25:
26: void
27: NC_free_cdf(handle)
28: NC *handle ;
29: {
30: if(handle == NULL)
31: return ;
32:
33: NC_free_xcdf(handle) ;
34:
35: xdr_destroy(handle->xdrs) ;
36: Free(handle->xdrs) ;
37: Free(handle) ;
38: }
39:
40:
41: NC *
42: NC_new_cdf(name, mode)
43: const char *name ;
44: int mode ;
45: {
46: NC *cdf ;
47:
=== 2:Dialog =====================$cdf#35==================================== =|
|- 4:Examine ----------------------------||- 3:handle->xdrs ----------------|
| [DS:3EE314] struct { | (struct *) ::xdrs = 0x003ee314 |
| enum xdr_op x_op = XDR_DECODE |---------------------------------|
| struct xdr_ops *x_ops = 0x001245a0
| x_public = ""
| x_private = "\5"
| x_base = 0x00000000
| x_handy = 0
| } ::xdrs
|----------------------------------------|
|= 5:Call Stack ==============================================================|
| 0 NC_free_var(var = 0xffffffff) from array.c#348
| 1 NC_free_array(array = 0x003ee498) from cdf.c#22
| 2 NC_free_xcdf(handle = 0x003ee1d0) from cdf.c#35
| 3 NC_free_cdf(handle = 0x003ee1d0) from cdf.c#84
| 4 NC_new_cdf(name = "c:\testdata\f50.nc", mode = 1) from file.c#100
| 5 NC_open(path = "c:\testdata\f50.nc", mode = 1) from file.c#145
| 6 ncopen(path = "c:\testdata\f50.nc", mode = 1) from dsdata.c#3349
| 7 RecordOpen(filename = "f50.nc", varName = "V10", path = "c:\testdata") fr
|=============================================================================|
In the third page we are in file cdf.c at line #84 one more step up and the
last page we printed. Window 4 is displaying *cdf. We omitted the call
stack display for this page.
=== 1:Source ==================================================================|
74: cdf->vars = NULL ;
75: cdf->begin_rec = 0 ;
76: cdf->recsize = 0 ;
77: cdf->numrecs = 0 ;
78: cdf->redefid = -1 ;
79:
80: if(cdf->xdrs->x_op == XDR_DECODE) /* Not NC_CREAT */
81: {
82: if(!xdr_cdf(cdf->xdrs, &cdf) )
83: {
84: NC_free_cdf(cdf) ;
85: return(NULL) ;
86: }
87: if( NC_computeshapes(cdf) == -1)
88: return(NULL) ;
89: }
90:
91: return(cdf) ;
92: }
93:
94:
95: /*
96: * Duplicate a description structure.
97: * Can only be called for 'old' extant on disk, eg, old in DATA mode.
98: */
99: NC *
=== 2:Dialog =====================$cdf#84==================================== =|
|-3:cdf -----------------------|
| (struct *) cdf = 0x003ee1d0 |
|------------------------------|
|-4:Examine ------------------------------------------------------------------|
| [248] = '\252' (0xaa 170), [249] = '\252' (0xaa 170), [250] = '\252
| [252] = '\252' (0xaa 170), [253] = '\252' (0xaa 170), [254] = '\252
| }
| flags = 0x00000001
| struct *xdrs = 0x003ee314
| begin_rec = 0
| recsize = 0x00000000
| redefid = -1
| numrecs = 0x00000000
| struct *dims = 0x003ee34c
| struct *attrs = 0x00000000
| struct *vars = 0x003ee498
| }
|-----------------------------------------------------------------------------|
Best Regards,
Eric Bachalo
Software Manager
Aerometrics, Inc. e-mail: eric@xxxxxxxxxxxxxxx
550 Del Rey Avenue voice: 408-738-6688
Sunnyvale, CA, USA 94086 fax: 408-738-6871