LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

[Bug] TDMS Read is deleting file on error

Solved!
Go to solution

A colleague and I ran across this one today. If the TDMS file is empty (ie. a completely blank, zero byte file), and is attempted to be read, the TDMS Read VI will delete the file. I'd consider this behaviour fairly serious - LabVIEW shouldn't delete any user files, regardless of the type of read error.

 

TDMS_delete_bug.png

 

The attached zip contains both this VI and test.tdms.




Certified LabVIEW Architect
Unless otherwise stated, all code snippets and examples provided
by me are "as is", and are free to use and modify without attribution.
0 Kudos
Message 1 of 8
(4,829 Views)

Confirmed behavior on 2016 and 2015 SP1.  It does seem odd and should be fixed.  I think the risk of data loss is small, but possible.  Interestingly enough the delete happes on the Close function.  Open creates a 0KB index file, then after the close both files are deleted.

0 Kudos
Message 2 of 8
(4,779 Views)

How did you create the empty 0 byte TDMS file? When you create a blank TDMS in LabVIEW using the open TDMS function, the size is 65 bytes, which tells me that there is some meta data that LabVIEW needs for the file to be read and closed correctly.

 

If you change the TDMS open option to open (read-only), and follow it immediately by a TDMS close, you will get an error -2503, which states that "Specified file does not comply with TDMS file format standards." The file also does not get deleted in this case. 

 

If you remove the read TDMS and rewire, with the default open option on the TDMS open, the TDMS file doesn't get deleted, and actually changes file size from 0 bytes to 65 bytes. It seems like LabVIEW is adding header data and other stuff as long as there is no TDMS read. If it tries to read the invalid TDMS file, it deletes the file.

 

Is there a particular reason you are trying to open a 0 byte TDMS file you created externally from LabVIEW, and did you make the file by changing a text file name to test.tdms? If that's how you created it, just note that just because the name says it's a .tdms doesn't necessarily mean it's a valid TDMS file. Also, if that's how you created the 0 byte TDMS file, Windows gives you a warning saying "If you change a file name extension, the file might become unusable." So if that's how you created the file, just note that it is not necessarily a valid way to create a fully-usable TDMS file. If you are creating it any other way please let me know.

 

I also tried clearing the error, before and after the close TDMS function, and the file was still deleted, so I don't think the file is being deleted because of the error. It might be happening because LabVIEW doesn't recognize the 0 byte file as a valid TDMS file when it tries to read the file.

 

I'll look into this further to try to get more information and possibly file corrective action for this odd occurance.

 

0 Kudos
Message 3 of 8
(4,755 Views)

Thanks for looking into this issue.

 

The file was created by hand (a text file with a renamed extension), and was just a placeholder for testing some other system functionality. It just so happened the file was passed through the TDMS functions during testing, and suddenly it disappeared from disk. I'm fully aware it's not a valid TDMS file, and was expecting the TDMS functions to throw errors. What I wasn't expecting was the file to be deleted.

 

I'll do some more testing to see if the file is deleted in any other scenarios.




Certified LabVIEW Architect
Unless otherwise stated, all code snippets and examples provided
by me are "as is", and are free to use and modify without attribution.
0 Kudos
Message 4 of 8
(4,750 Views)

Okay so it is clear that files like this shouldn't exist.  But this is still a bug right?  Files are being deleted from the file system that were not asked to be deleted.  When a CAR gets created please post the CAR number here for tracking purposes.

0 Kudos
Message 5 of 8
(4,731 Views)

I'm in the process of submitting a CAR. 

I'll post the number here when it's available.

Thank you

0 Kudos
Message 6 of 8
(4,717 Views)

A CAR has been filed: #629258.

Thank you for finding this bug!

Message 7 of 8
(4,709 Views)
Solution
Accepted by MichaelBalzer

CAR 629258 is fixed in LabVIEW 2018

Message 8 of 8
(4,047 Views)