1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-21 10:13:43 +03:00

0032894: Application Framework - Regressions on Ubuntu 20.04

Updated corrupted file reading error management, make memory unit-tests more stable.
This commit is contained in:
mpv 2022-06-20 17:45:27 +03:00
parent 94748ad20e
commit f8c45c2f0d
5 changed files with 20 additions and 9 deletions

View File

@ -229,11 +229,12 @@ void BinLDrivers_DocumentRetrievalDriver::Read (Standard_IStream&
if (aFileVer >= TDocStd_FormatVersion_VERSION_3) { if (aFileVer >= TDocStd_FormatVersion_VERSION_3) {
BinLDrivers_DocumentSection aSection; BinLDrivers_DocumentSection aSection;
do { do {
BinLDrivers_DocumentSection::ReadTOC (aSection, theIStream, aFileVer); if (!BinLDrivers_DocumentSection::ReadTOC (aSection, theIStream, aFileVer))
break;
mySections.Append(aSection); mySections.Append(aSection);
} while (!aSection.Name().IsEqual (aQuickPart ? ENDSECTION_POS : SHAPESECTION_POS) && !theIStream.eof()); } while (!aSection.Name().IsEqual (aQuickPart ? ENDSECTION_POS : SHAPESECTION_POS) && !theIStream.eof());
if (theIStream.eof()) { if (mySections.IsEmpty() || theIStream.eof()) {
// There is no shape section in the file. // There is no shape section in the file.
myMsgDriver->Send (aMethStr + "error: shape section is not found", Message_Fail); myMsgDriver->Send (aMethStr + "error: shape section is not found", Message_Fail);
myReaderStatus = PCDM_RS_ReaderException; myReaderStatus = PCDM_RS_ReaderException;

View File

@ -214,14 +214,17 @@ void BinLDrivers_DocumentSection::Write (Standard_OStream& theStream,
//purpose : //purpose :
//======================================================================= //=======================================================================
void BinLDrivers_DocumentSection::ReadTOC Standard_Boolean BinLDrivers_DocumentSection::ReadTOC (
(BinLDrivers_DocumentSection& theSection, BinLDrivers_DocumentSection& theSection,
Standard_IStream& theStream, Standard_IStream& theStream,
const TDocStd_FormatVersion theDocFormatVersion) const TDocStd_FormatVersion theDocFormatVersion)
{ {
char aBuf[512]; static const int THE_BUF_SIZE = 512;
char aBuf[THE_BUF_SIZE];
Standard_Integer aNameBufferSize; Standard_Integer aNameBufferSize;
theStream.read ((char *)&aNameBufferSize, sizeof(Standard_Integer)); theStream.read ((char *)&aNameBufferSize, sizeof(Standard_Integer));
if (theStream.eof() || aNameBufferSize > THE_BUF_SIZE)
return Standard_False;
#ifdef DO_INVERSE #ifdef DO_INVERSE
aNameBufferSize = InverseSize(aNameBufferSize); aNameBufferSize = InverseSize(aNameBufferSize);
#endif #endif
@ -260,4 +263,5 @@ void BinLDrivers_DocumentSection::ReadTOC
theSection.myValue[1] = aValue[1]; theSection.myValue[1] = aValue[1];
theSection.myIsPostRead = (aValue[2] != 0); theSection.myIsPostRead = (aValue[2] != 0);
} }
return Standard_True;
} }

View File

@ -73,9 +73,10 @@ public:
const TDocStd_FormatVersion theDocFormatVersion); const TDocStd_FormatVersion theDocFormatVersion);
//! Fill a DocumentSection instance from the data that are read //! Fill a DocumentSection instance from the data that are read
//! from TOC. //! from TOC. Returns false in case of the stream reading problem.
Standard_EXPORT static void ReadTOC (BinLDrivers_DocumentSection& theSection, Standard_IStream& theIS, Standard_EXPORT static Standard_Boolean ReadTOC (BinLDrivers_DocumentSection& theSection,
const TDocStd_FormatVersion theDocFormatVersion); Standard_IStream& theIS,
const TDocStd_FormatVersion theDocFormatVersion);

View File

@ -20,5 +20,5 @@ for {set i 1} {${i} <= ${i_max}} {incr i} {
# check memory usage (with tolerance equal to half page size) # check memory usage (with tolerance equal to half page size)
lappend listmem [meminfo h] lappend listmem [meminfo h]
checktrend $listmem 0 1 "Memory leak detected" checktrend $listmem 50 50 "Memory leak detected"
} }

View File

@ -8,6 +8,11 @@ NewDocument D BinOcaf
SaveAs D $docname SaveAs D $docname
Close D Close D
# make the first open/close iteration before checking memory because some filled structures
# are cleared on start of the next open (like mySections in DocumentRetrievalDriver)
Open $docname D
Close D
puts "Executing Load / Close in cycle to see if allocated heap memory grows" puts "Executing Load / Close in cycle to see if allocated heap memory grows"
set listmem {} set listmem {}
for {set i 1} {$i < 10} {incr i} { for {set i 1} {$i < 10} {incr i} {