HydrologicEngineeringCenter / hec-dss

source code for HEC-DSS (Data Storage System)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

memory issue(s) when converting from DSS version 7 to DSS Version 6

ktarbet opened this issue · comments

Items to note from initial investigation:

4:17:58.751 -----DSS--- zread Handle 3; Version 15: //JATO/FLOW-OBSERVED/01Jul2023/1Hour/FOR:Realtime-Snow:S0S0/
14:17:58.752
14:17:58.752
14:17:58.752 ***** DSS *** ERROR in function ztsStore: Cannot allocate memory, size requested: %d
14:17:58.752 Error occurred in HEC-DSS version 6, message: Copying time series VDI to user header

Branch DSS-178 (in this repo) added a method to the test program for debugging
https://github.com/HydrologicEngineeringCenter/hec-dss/tree/DSS-178

convert James_river.dss   output-v6.dss

The record //JATO/Location Info////
has this record. is supplementalInfo: (without any data) a valid tag?

supplementalInfo:verticalDatumInfo:H4sIAAAAAAAACrMpSy0qyUxOzNFNSSwpzdXNzEvLVyjNyyyxVUorUbLjUlCwyUssySxLhcjb+Yd4uAbZ6KOIgRTl5CPMyEvMTbUL9fP28w/3s9HHkOGy0cdiqR0DABIMJZeLAAAA;

The above was found using the Display->Raw Data menu of DSSVue

In verticalDatum.c:290 The code, below, is overwriting a \0 in some cases. We may need to add the condition [&& len < delimitedStringSize]

int len = strlen(*delimitedString);
    if (len > 0 && (*delimitedString)[len-1] != delimiter) {
		(*delimitedString)[len++] = delimiter;
    }



in ztsStore: (about line 352)  -- using tss->pathname  after call to zstructFree(tss);
The calling  program will free tss;  do we need to free memory here?

```C		if (status != STATUS_OKAY) {
			zstructFree(tss);
			return zerrorProcessing(ifltab, DSS_FUNCTION_ztsStore_ID,
				zdssErrorCodes.CANNOT_ALLOCATE_MEMORY, 0, 0,
				zdssErrorSeverity.MEMORY_ERROR,
				tss->pathname, "Copying time series VDI to user header");
		}

See also : DSS-178 - Java crash when converting record from v7 to v6. That includes the following Junit test.

    public void convert_7_to_6_crash_DSS_178() throws Exception{
        String filename7 = TestFiles.getFile("James_River.dss",true);
        String filename6 = TestFiles.getFile("James_River6",false);

        HecDSSUtilities u = new HecDSSUtilities();
        u.setDSSFileName(filename7);
        Vector<hec.heclib.dss.CondensedReference> v7Catalog = u.getCondensedCatalog();

        u.convertVersion(filename6);
        u.close();
        u.setDSSFileName(filename6);
        Vector<hec.heclib.dss.CondensedReference> v6Catalog = u.getCondensedCatalog();

        assertEquals(v7Catalog.size()-2,v6Catalog.size());// drop location info in DSS6
    }

James_River.zip

I believe this is all handled in the updated DSS-178 branch, which has already been merged.

I Verified the fix using the DSS-C test program.

Verified Java test, closing.