Bug report

I attempted to build the distribution here today, and found the following:

Summary: test_ncopen() fails if temporary files are on a different
filesystem.  "nctest" then crashes because of faulty error recovery
logic.  Error was found on a SunOS Release 4.1.1 system.

In src/file.c, the temporary file being renamed at line 735 (NC_endef()),
may result in a cross device link error, and subsequent error
recovery leads to an attempt to dereference a null pointer.


if( rename(handle->path, stash->path) != 0)
At this point,

        stash->path = "test.cdf"
        handle->path = "/tmp/nc.AAAa03280"

These are on different filesystems here (errno points to "cross device link")!

Then, NC_free_cdf(handle) is called, and STASH[cdfid] is set to NULL.

This makes ncendef() return -1, detected in cdftests.c at line 110.
The real fun begins when ncclose() is called.  The entry in _cdfs[]
is valid, but the entry in STASH has been set to NULL in the handling
of the rename error.  Finally, in function NC_endef in file.c (line 671)
an attempt is made to dereference stash, and the test dies.

All this appears to be a result of Sun's tempnam() function not working
as advertised.  The contents of "scratchfile" after the call to

tempnam((getcwd(NULL,FILENAME_MAX),"nc.")

is "/tmp/nc.<stuff>".  This is NOT what's expected, and NOT what Sun's
man page says will happen.  (Note that even if the call worked, this is
a small memory leak, since getcwd(NULL,...) does a malloc, and the
code just uses the return, and thus can't free the memory.

Jim
--
James G. Watt                                          jimw@xxxxxxxxxxxxx
PE-Nelson                                              +1 408 725 1107 x357
10040 Bubb Road
Cupertino, CA 95014


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