Archived issue #0024007
[Regression] Sporadic crashes when working with XDE documents
Description
Steps to reproduce
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 new test case is required.
Public activity
12 archived notes
Participants are labeled by their role within this record.
The fix has been pushed to the git repository.
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!
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!
Thanks Commenter 2. Yes, please confirm if this helps your case.
FYI - OCC tests "testgrid xcaf" do pass. So do proprietary CAD Exchanger's.
FYI - OCC tests "testgrid xcaf" do pass. So do proprietary CAD Exchanger's.
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?
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?
Hi Commenter 2,
can you post a stack trace ?
can you post a stack trace ?
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
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
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
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
Sorry for lacking precision ;)
I meant the TDF_Label (0x000000000a00b818) containing the XCAFDoc_Color attribute.
Unfortunately, I was not able to create a reproducer...
I meant the TDF_Label (0x000000000a00b818) containing the XCAFDoc_Color attribute.
Unfortunately, I was not able to create a reproducer...
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.
Branch CR24007 is ready to be tested.
Dear Commenter 1,
Branch CR24007 (and products from GIT master) was compiled on Linux and Windows platforms and tested.
[revision removed]
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.
Branch CR24007 (and products from GIT master) was compiled on Linux and Windows platforms and tested.
[revision removed]
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.
Related records
- #0023523 · related to · closedIn session DRAW it is impossible to close document having name already once closed document.
- #0023593 · related to · closedXCAFDoc_DocumentTool label must be removed from internal map upon closing the XDE document
- #0024047 · related to · closedException in TPrsStd_AISPresentation during destruction of TDocStd_Document
- #0024164 · related to · closedOptimization of OCAF document closing