View Issue Details

IDProjectCategoryView StatusLast Update
0024931CommunityOCCT:Foundation Classespublic2015-02-07 08:42
ReporterRoman Lygin Assigned Toapn  
Status closedResolutionfixed 
Target Version6.8.0Fixed in Version6.8.0 
Summary0024931: Stack overflow when writing large shapes to XML
DescriptionLDOM_OSStream runs into stack overflow when writing large shape sections in XML documents (e.g. in XML persistence).
The root-cause is recursive destruction of siblings holding memory chunks. With a memory chunk hard-coded at 1KB large documents require >50K chunks. So the destructor, recursively called, leads to stack overflow.

The fix includes refactoring of the code and use of NCollection_IncAllocator.
This allowed to avoid need of destructor and improve performance.
Additionally the chunk is increased to 16K to reduce need for extra allocations/deallocations, what also should improve performance.
Steps To ReproduceSee enclosed test case.
TagsNo tags attached.
Test case numberbugs fclasses bug24931

Attached Files

  • (974 bytes)


related to 0025803 closedbugmaster Open CASCADE Defective tests contaminating current directory 


Roman Lygin

2014-05-15 20:28

developer (974 bytes)

Roman Lygin

2014-05-15 21:10

developer   ~0029362

The fix pushed into git.


2014-05-20 18:10

manager   ~0029417

Reviewed, can be tested.

One minor remark: it would be logical to make the field myAlloc in LDOM_OSStream having the type NCollection_IncAllocator, and add appropriate comment to the field declaration, to make it more explicit that incallocation is essential here.

And one more point: could you provide result of performance increase measured due to that change?

Roman Lygin

2014-05-20 19:49

developer   ~0029419

Hi Andrey,
Thanks for the review. Yeah, I initially thought of exposing IncAllocator into the header but then pulled back to make the header to only depend on the base class header file (NCollection_BaseAllocator.hxx). The field is private, so no subclass or callers can adversely influence that, and the comment was put into the .cxx file instead.

Regarding performance I did not make intensive measurements but quick tests on the test file exhibited single digit differences - 3%-7% difference AFAIR. No big deal of course - apparently the greater performance loss happens somewhere else.


2014-05-28 15:44

administrator   ~0029575

Dear BugMaster,

Branch CR24931 (and products from GIT master) was compiled on Linux, Windows and MacOS platforms and tested.
SHA-1: 72cd339f5cd418f580adc351b79f7c7d07072834

Number of compiler warnings:

occt component :
Linux: 17 (17 on master)
Windows: 0 (0 on master)
MacOS: 202 (205 on master)

products component :
Linux: 11 (11 on master)
Windows: 2 (2 on master)

No regressions

Testing cases:
bugs fclasses bug24931 - OK

Testing on Linux:
Total MEMORY difference: 359574056 / 359742796
Total CPU difference: 52411.48999999997 / 51526.670000000115

Testing on Windows:
Total MEMORY difference: 381754716 / 382610904
Total CPU difference: 38105.40625 / 37430.125

There are no differences in images found by testdiff.

Roman Lygin

2014-10-15 15:16

developer   ~0033136

Verified as fixed in 6.8.0 beta.

Related Changesets

occt: master 70167e69

2014-05-29 12:08:40

Roman Lygin

Committer: apn Details Diff
0024931: Stack overflow when writing large shapes to XML

Added QA command OCC24931 and test case bugs/fclasses/bug24931
Affected Issues
mod - src/LDOM/LDOM_OSStream.cxx Diff File
mod - src/LDOM/LDOM_OSStream.hxx Diff File
mod - src/QABugs/QABugs_19.cxx Diff File
mod - src/XmlMNaming/XmlMNaming_NamedShapeDriver.cxx Diff File
add - tests/bugs/fclasses/bug24931 Diff File

Issue History

Date Modified Username Field Change
2014-05-15 20:25 Roman Lygin New Issue
2014-05-15 20:25 Roman Lygin Assigned To => abv
2014-05-15 20:28 Roman Lygin File Added:
2014-05-15 21:10 Roman Lygin Note Added: 0029362
2014-05-15 21:10 Roman Lygin Status new => resolved
2014-05-20 18:10 abv Note Added: 0029417
2014-05-20 18:10 abv Assigned To abv => bugmaster
2014-05-20 18:10 abv Status resolved => reviewed
2014-05-20 19:49 Roman Lygin Note Added: 0029419
2014-05-22 11:07 bugmaster Target Version => 6.8.0
2014-05-22 11:07 bugmaster Description Updated
2014-05-27 13:20 apn Assigned To bugmaster => apn
2014-05-28 15:44 apn Note Added: 0029575
2014-05-28 15:45 apn Test case number => bugs fclasses bug24931
2014-05-28 15:45 apn Assigned To apn => bugmaster
2014-05-28 15:45 apn Status reviewed => tested
2014-05-30 12:59 apn Changeset attached => occt master 70167e69
2014-05-30 12:59 apn Assigned To bugmaster => apn
2014-05-30 12:59 apn Status tested => verified
2014-05-30 12:59 apn Resolution open => fixed
2014-10-15 15:16 Roman Lygin Note Added: 0033136
2014-11-11 12:44 aiv Fixed in Version => 6.8.0
2014-11-11 12:59 aiv Status verified => closed
2015-02-07 08:42 abv Relationship added related to 0025803