This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
>From: Masaki Fukuda <address@hidden> >Subject: I got UMR(Uninitialized Memory Read) in netcdf-3.5.0 >Organization: BCDE >Keywords: 200209160323.g8G3N8118906 netCDF 3.5 uninitialized memory read Hi, > Thank you for excellent tool, netcdf. > I'm using netcdf for analizing and visualizing of weather data. > > Sometime, My application coredumped by SEGV 11(Segmentation > Violation). then I checked memory access by Purify(produced by > RationalRose), and I got UMR(Uninitialized Memory Read) errors. > > Some information: > NetCDF Version: 3.5.0 > Environment > purify check: Solaris 2.5.1(gcc version 2.95.3 20010315) > coredump : Redhat7.2(gcc version 2.96 20000731 > (Red Hat Linux 7.1 2.96-98)) > > I think the pointer expected to initialize NULL(see the patch which > attached in this mail). > > Am I correct?, Is this a bug? > If correct, I'm appliciated that the bug fixed in the next version. Just looking at the source code, I can't verify that this is a bug, since the void *xp; statement just declares a pointer location that should be set by the later use of &xp as a parameter to a function that sets a value in this location. However, it's hard to tell without a program that reproduces the bug, and I can't see any harm in replacing the declarations with void *xp = 0; I just ran the "make test" code under Purify in the nc_test directory and saw lots of UMR errors, even though all the tests passed. I'll have to investigate further to see if the fix you suggested gets rid of the UMRs but thanks for sending it in. > Can you understand my funny english? Yes, it's fine. Your English is much better than my Japanese! > -- begin on patch -- netcdf-3.5.0/src/libsrc/putget.c > ------------------------------------------------------- > *** putget.c Tue Sep 10 17:27:54 2002 > --- putget.c.org Thu Oct 29 02:36:00 1998 > *************** > *** 1893,1899 **** > off_t offset = NC_varoffset(ncp, varp, start); > size_t remaining = varp->xsz * nelems; > int status = NC_NOERR; > ! void *xp=0; > > if(nelems == 0) > return NC_NOERR; > --- 1893,1899 ---- > off_t offset = NC_varoffset(ncp, varp, start); > size_t remaining = varp->xsz * nelems; > int status = NC_NOERR; > ! void *xp; > > if(nelems == 0) > return NC_NOERR; > *************** > *** 3580,3586 **** > off_t offset = NC_varoffset(ncp, varp, start); > size_t remaining = varp->xsz * nelems; > int status = NC_NOERR; > ! const void *xp=0; > > if(nelems == 0) > return NC_NOERR; > --- 3580,3586 ---- > off_t offset = NC_varoffset(ncp, varp, start); > size_t remaining = varp->xsz * nelems; > int status = NC_NOERR; > ! const void *xp; > > if(nelems == 0) > return NC_NOERR; > > -- --Russ