root icon indicating copy to clipboard operation
root copied to clipboard

[TNDArrayT] Backward incompatibility: Error reading from ROOT Files created with earlier versions - Streamer bug

Open Triple-S opened this issue 2 years ago • 5 comments

Describe the bug

It is currently impossible to read TNDArrayT objects from ROOT Files created with earlier ROOT Versions than v6.26. This affects primarily THn Objects which have this class as a data member. The problem is caused by this commit: https://github.com/root-project/root/commit/afb95216eeec9dea2d4aab35231b64e067c8af57 where a datamemember of TNDArrayT was changed, but the Streamer generation information were not updated appropriately.

The following error messages are displayed if one attepts to read a TNDArrayT from an earlier ROOT version: Warning in <TStreamerInfo::BuildOld>: Cannot convert TNDArray::fSizes from type: Long64_t* to type: vector<Long64_t>, skip element Warning in <TStreamerInfo::Compile>: Counter fNdimPlusOne should not be skipped from class TNDArray Warning in <TStreamerInfo::BuildOld>: Cannot convert TNDArrayT<double>::fData from type: double* to type: vector<double>, skip element Warning in <TStreamerInfo::Compile>: Counter fNumData should not be skipped from class TNDArrayT<double> Error in <TBufferFile::CheckByteCount>: object of class TNDArray read too few bytes: 17 instead of 57 Error in <TBufferFile::CheckByteCount>: object of class TNDArrayT<double> read too few bytes: 68 instead of 200866628 Warning in <TStreamerInfo::BuildOld>: Cannot convert TNDArrayT<float>::fData from type: float* to type: vector<float>, skip element Warning in <TStreamerInfo::Compile>: Counter fNumData should not be skipped from class TNDArrayT<float> Error in <TBufferFile::CheckByteCount>: object of class TNDArray read too many bytes: 2057 instead of 57 Warning in <TBufferFile::CheckByteCount>: TNDArray::Streamer() not in sync with data on file XXX, fix Streamer() Error in <TBufferFile::CheckByteCount>: object of class TNDArrayT<float> read too few bytes: 1088 instead of 100433348 Error in <TBufferFile::CheckByteCount>: object of class TNDArray read too few bytes: 17 instead of 57 Error in <TBufferFile::CheckByteCount>: object of class TNDArrayT<double> read too few bytes: 68 instead of 200866628 Error in <TBufferFile::CheckByteCount>: object of class TNDArray read too many bytes: 100369 instead of 57 Warning in <TBufferFile::CheckByteCount>: TNDArray::Streamer() not in sync with data on file XXX, fix Streamer() Error in <TBufferFile::CheckByteCount>: object of class TNDArrayT<float> read too few bytes: 50244 instead of 100433348

Expected behavior

Expected behavior is that the object is read properly and the Streamer takes care of all required conversions from the old to the new data format.

To Reproduce

  • Create a ROOT-File containing a THn with an earlier ROOT version. e.g. v6.24.06
  • Try to read the object from the created ROOT-File with ROOT version v6.26.00.

Triple-S avatar Apr 12 '22 07:04 Triple-S

We are probably missing an I/O rule along the line of

#pragma read sourceClass="TNDArrayT<float>" targetClass="TNDArrayT<float>" source="Int_t fNumData; float *fData;" target="fData" versions="1" code="{ fData.clear(); for(int i = 0; i < onfile.fNumData; ++i) fData.push_back(onfile.fData[i]); }"

pcanal avatar Apr 12 '22 13:04 pcanal

If it is useful to know, this bug persists with v6.26.02 as well as v6.26.04.

Warning in <TStreamerInfo::BuildOld>: Cannot convert TNDArray::fSizes from type: Long64_t* to type: vector<Long64_t>, skip element
Warning in <TStreamerInfo::Compile>: Counter fNdimPlusOne should not be skipped from class TNDArray
Warning in <TStreamerInfo::BuildOld>: Cannot convert TNDArrayT<double>::fData from type: double* to type: vector<double>, skip element
Warning in <TStreamerInfo::Compile>: Counter fNumData should not be skipped from class TNDArrayT<double>
Error in <TBufferFile::CheckByteCount>: object of class TNDArray read too few bytes: 17 instead of 57
Error in <TBufferFile::CheckByteCount>: object of class TNDArrayT<double> read too few bytes: 68 instead of 76880068
Warning in <TStreamerInfo::BuildOld>: Cannot convert TNDArrayT<float>::fData from type: float* to type: vector<float>, skip element
Warning in <TStreamerInfo::Compile>: Counter fNumData should not be skipped from class TNDArrayT<float>
Error in <TBufferFile::CheckByteCount>: object of class TNDArray read too few bytes: 17 instead of 57
Error in <TBufferFile::CheckByteCount>: object of class TNDArrayT<float> read too few bytes: 68 instead of 38440068
Error in <TBufferFile::CheckByteCount>: object of class TNDArray read too few bytes: 17 instead of 57
Error in <TBufferFile::CheckByteCount>: object of class TNDArrayT<double> read too few bytes: 68 instead of 76880068

ezradlesser avatar Jul 15 '22 08:07 ezradlesser

patch.txt

pzhristov avatar Sep 22 '22 07:09 pzhristov

I tried the patch above and it seems to solve the problem.

pzhristov avatar Sep 22 '22 07:09 pzhristov

ok, I'll make a PR using that patch. Thank you !

lmoneta avatar Sep 22 '22 08:09 lmoneta

Hi @lmoneta,

It appears this issue is closed, but wasn't yet added to a project. Please add upcoming versions that will include the fix, or 'not applicable' otherwise.

Sincerely, :robot:

github-actions[bot] avatar Sep 26 '22 06:09 github-actions[bot]

Hi @lmoneta,

It appears this issue is closed, but wasn't yet added to a project. Please add upcoming versions that will include the fix, or 'not applicable' otherwise.

Sincerely, :robot:

github-actions[bot] avatar Sep 27 '22 06:09 github-actions[bot]

Hi @lmoneta,

It appears this issue is closed, but wasn't yet added to a project. Please add upcoming versions that will include the fix, or 'not applicable' otherwise.

Sincerely, :robot:

github-actions[bot] avatar Sep 28 '22 06:09 github-actions[bot]

Hi @lmoneta,

It appears this issue is closed, but wasn't yet added to a project. Please add upcoming versions that will include the fix, or 'not applicable' otherwise.

Sincerely, :robot:

github-actions[bot] avatar Sep 29 '22 06:09 github-actions[bot]