MantisBT - Community
View Issue Details
0024007Community[OCCT] OCCT:Data Exchangepublic2013-06-02 11:412013-12-19 13:58
Roman Lygin 
Roman Lygin 
normalmajor 
closedfixed 
ALL
[OCCT] 6.6.0 
[OCCT] 6.7.0[OCCT] 6.7.0 
Not needed
0024007: [Regression] Sporadic crashes when working with XDE documents
The fix 0023523 has changed the order of destroying the document contents: destructors of the attributes are now called with null Label().
This invalidates the fix 0023593 and resurrects the problem.

The current fix removes a global map and thus eliminates a risk of orphan labels.
Apparently the problem is not captured by OCC automatic tests due to different memory allocator - as the problem shows up when there is a clash of the addresses - when a root label gets the same address as already destroyed one.

No new test case is required.
No tags attached.
related to 0023523closed gka Open CASCADE In session DRAW it is impossible to close document having name already once closed document. 
related to 0023593closed Roman Lygin Community XCAFDoc_DocumentTool label must be removed from internal map upon closing the XDE document 
related to 0024047closed gka Open CASCADE Exception in TPrsStd_AISPresentation during destruction of TDocStd_Document 
related to 0024164closed bugmaster Open CASCADE Optimization of OCAF document closing 
png crash_DocumentClosing.png (15,936) 2013-06-03 14:16
https://tracker.dev.opencascade.org/
Issue History
2013-06-02 11:41Roman LyginNew Issue
2013-06-02 11:41Roman LyginAssigned To => gka
2013-06-02 11:46Roman LyginNote Added: 0024590
2013-06-02 11:46Roman LyginStatusnew => resolved
2013-06-02 12:05Roman LyginNote Added: 0024591
2013-06-02 12:18Roman LyginRelationship addedrelated to 0023523
2013-06-02 12:18Roman LyginRelationship addedrelated to 0023593
2013-06-02 15:10PawelNote Added: 0024593
2013-06-02 15:58Roman LyginNote Added: 0024594
2013-06-03 13:22PawelNote Added: 0024602
2013-06-03 13:28Roman LyginNote Added: 0024603
2013-06-03 14:16PawelFile Added: crash_DocumentClosing.png
2013-06-03 14:21PawelNote Added: 0024604
2013-06-03 14:45Roman LyginNote Added: 0024607
2013-06-03 14:46Roman LyginNote Added: 0024608
2013-06-03 14:46Roman LyginNote Edited: 0024607bug_revision_view_page.php?bugnote_id=24607#r5466
2013-06-03 14:46Roman LyginNote Deleted: 0024608
2013-06-03 15:01PawelNote Added: 0024611
2013-06-05 17:54PawelNote Added: 0024641
2013-06-26 12:19gkaRelationship addedrelated to 0024047
2013-07-01 12:13gkaNote Added: 0024925
2013-07-01 12:13gkaStatusresolved => reviewed
2013-07-01 13:12mkvAssigned Togka => mkv
2013-07-03 11:43mkvNote Added: 0024952
2013-07-03 11:43mkvTest case number => Not needed
2013-07-03 11:43mkvAssigned Tomkv => bugmaster
2013-07-03 11:43mkvStatusreviewed => tested
2013-07-03 11:44apnTarget Version => 6.7.0
2013-07-05 11:57Roman LyginChangeset attached => occt master 388fc344
2013-07-05 11:57Roman LyginAssigned Tobugmaster => Roman Lygin
2013-07-05 11:57Roman LyginStatustested => verified
2013-07-05 11:57Roman LyginResolutionopen => fixed
2013-10-02 15:52abvRelationship addedrelated to 0024164
2013-12-19 13:52bugmasterStatusverified => closed
2013-12-19 13:58bugmasterFixed in Version => 6.7.0

Notes
(0024590)
Roman Lygin   
2013-06-02 11:46   
The fix has been pushed to the git repository.
(0024591)
Roman Lygin   
2013-06-02 12:05   
See more details in http://opencascade.blogspot.com/2013/06/significant-side-effects-in-ocafxde-660.html [^]
(0024593)
Pawel   
2013-06-02 15:10   
Hello Roman,

as stated in 0023554 since then I've dealt with some occasional crashes upon XDE document destruction I was not able to identify. Mostly freeing labels with XCAFDoc_ColorTool caused the problem but neither was I able to reproduce nor to isolate it.

I'll test your fix tomorrow and hope I can give positive feedback.

Thank you!
(0024594)
Roman Lygin   
2013-06-02 15:58   
Thanks Pawel. Yes, please confirm if this helps your case.
FYI - OCC tests "testgrid xcaf" do pass. So do proprietary CAD Exchanger's.
(0024602)
Pawel   
2013-06-03 13:22   
Hello Roman,

I have applied this fix and followed your advice to store the handle to the AIS_InteractiveContext outside the document. It seems to help in most cases...

However, I still have one XDE file (unfortunately cutomer data) that does crash upon closing the document. As described above, the problem is XCAFDoc_ColorTool attribute.

Do you think there might be a similar issue with XCAFDoc_*Tool attributes as the one corrected by you?
(0024603)
Roman Lygin   
2013-06-03 13:28   
Hi Pawel,
can you post a stack trace ?
(0024604)
Pawel   
2013-06-03 14:21   
Hi Roman,

I attached a picture to clarify.

The crash occurs when 'forgetting' a XCAFDoc_ColorTool sub-label (0x000000000a00b818). Precisely, when forgetting TDataStd_TreeNode attribute.

TDF_Label::ForgetFromNode crashes in line 601:

    if (fromNode->Data()->NotUndoMode()) {

Below stack trace.

If you have any questions please let me know.

Unfortunately, lots of internal OCCT mechanisms are beyond my understanding so I'm very happy about any help on the issue. Thanks!

TKLCAF.dll!TDF_Label::ForgetFromNode(TDF_LabelNode * const & fromNode=0x000000000a00b818, const Handle_TDF_Attribute & anAttribute={...}) Line 601
TKLCAF.dll!TDF_Label::ForgetAllAttributes(const unsigned int clearChildren=1) Line 500 + 0x1a Bytes
TKLCAF.dll!TDF_Label::ForgetAllAttributes(const unsigned int clearChildren=1) Line 508 + 0x1b Bytes
TKLCAF.dll!TDF_Label::ForgetAllAttributes(const unsigned int clearChildren=1) Line 508 + 0x1b Bytes
TKLCAF.dll!TDF_Label::ForgetAllAttributes(const unsigned int clearChildren=1) Line 508 + 0x1b Bytes
TKLCAF.dll!TDocStd_Document::Destroy() Line 81
TKLCAF.dll!TDocStd_Document::~TDocStd_Document() Line 224 + 0xa Bytes
TKLCAF.dll!TDocStd_Document::`scalar deleting destructor'() + 0x17 Bytes
TKernel.dll!Standard_Transient::Delete() Line 82 + 0x30 Bytes
TKernel.dll!Handle_Standard_Transient::EndScope() Line 58
(0024607)
Roman Lygin   
2013-06-03 14:45   
(edited on: 2013-06-03 14:46)
Thanks. Is this XCAFDoc_Color or _ColorTool ? The latter does not have a TreeNode attached to the same label, while the former - does.

Anyway, I briefly looked at the TDataStd_TreeNode::BeforeForget() and TDataStd_TreeNode::Remove(). They seem to be safe enough, and given that the trees can be directed in any direction, the changed behavior should not cause a side-effect (in theory).
There is however IsBackuped() check in ::BeforeForget() and perhaps another control flow causes different behavior.
I guess the only feasible way would be to have a C++ reproducer. DRAW seems to be too non-representative - there are multiple global objects (variables, AIS_IC, application, ...) holding handles to objects

(0024611)
Pawel   
2013-06-03 15:01   
Sorry for lacking precision ;)

I meant the TDF_Label (0x000000000a00b818) containing the XCAFDoc_Color attribute.

Unfortunately, I was not able to create a reproducer...
(0024641)
Pawel   
2013-06-05 17:54   
For the record: the problem with crash when deleting labels with XCAFDoc_Color attribute resulted from "damaged" XDE structure (cyclic dependency of TDataStd_TreeNode) and has nothing to do with the issue reported/corrected by Roman here.
(0024925)
gka   
2013-07-01 12:13   
Branch CR24007 is ready to be tested.
(0024952)
mkv   
2013-07-03 11:43   
Dear BugMaster,

Branch CR24007 (and products from GIT master) was compiled on Linux and Windows platforms and tested.
SHA-1: aa66e3b27d03a38213974173f43b18e46d032af5

Number of compiler warnings:

occt component :
Linux: 2 (2 on master)
Windows: 7 (7 on master)

products component :
Linux: 0 (0 on master)
Windows: 63 (63 on master)

Regressions:
No regressions

Improvements:
No improvements

Testing cases:
Not needed

Testing on Linux:
Total MEMORY difference: 366342436 / 366203376
Total CPU difference: 44579.97000000128 / 43388.71000000102

Testing on Windows:
Total MEMORY difference: 422133272 / 424066896
Total CPU difference: 32228.75 / 44233.921875

There are not differences in images found by testdiff.