Archived issue #0028889
Visualization, V3d_View - View specific Graphic3d_Structure should be removed if the view is removed
Description
There are some Graphic3d_Structure are view specific, such as V3d_Trihedron, Grid. These structure should be removed if the host view is removed and it will caused crash if not.
Please see below cases:
1. view->TriedronDisplay();
2. view->Remove();
3. view->StructureManager()->RecomputeStructures();
The last step will access deleted V3d_Trihedron pointer in below method:
class V3d_Trihedron::TrihedronStructure
virtual void Compute() Standard_OVERRIDE { myTrihedron->compute(); }
Please see below cases:
1. view->TriedronDisplay();
2. view->Remove();
3. view->StructureManager()->RecomputeStructures();
The last step will access deleted V3d_Trihedron pointer in below method:
class V3d_Trihedron::TrihedronStructure
virtual void Compute() Standard_OVERRIDE { myTrihedron->compute(); }
Steps to reproduce
N/A
Public activity
13 archived notes
Participants are labeled by their role within this record.
Though removing structures within V3d_View::Remove() would be correct,
I don't see what kind of problem you currently have.
V3d_Trihedron::myStructure is a handle to V3d_Trihedron::TrihedronStructure,
so that raw pointer V3d_Trihedron::TrihedronStructure::myTrihedron should never point to invalid address.
I don't get any crashes on your test case on current master.
I don't see what kind of problem you currently have.
V3d_Trihedron::myStructure is a handle to V3d_Trihedron::TrihedronStructure,
so that raw pointer V3d_Trihedron::TrihedronStructure::myTrihedron should never point to invalid address.
I don't get any crashes on your test case on current master.
Dear kgv,
V3d_View owns V3d_Trihedron object, and after V3d_View deleted, V3d_Trihedron will be deleted too. But the back reference inside class V3d_Trihedron::TrihedronStructure has a raw pointer reference to V3d_Trihedron, this pointer will be become to a dangling pointer pointer to a deleted object V3d_Trihedron. When the viewer update the Structure, it will access this dangling pointer to cause crash.
V3d_View owns V3d_Trihedron object, and after V3d_View deleted, V3d_Trihedron will be deleted too. But the back reference inside class V3d_Trihedron::TrihedronStructure has a raw pointer reference to V3d_Trihedron, this pointer will be become to a dangling pointer pointer to a deleted object V3d_Trihedron. When the viewer update the Structure, it will access this dangling pointer to cause crash.
Below compute method will access the dangling pointer myTrihedron:
class V3d_Trihedron::TrihedronStructure
virtual void Compute() Standard_OVERRIDE { myTrihedron->compute(); }
class V3d_Trihedron::TrihedronStructure
virtual void Compute() Standard_OVERRIDE { myTrihedron->compute(); }
OK, so the test code in the bug description should include NULLifying view before calling RecomputeStructures().
To reproduce this bug, please Remove() the view firstly and make sure V3d_Trihedron is deleted. V3d_Trihedron::TrihedronStructure::Compute() method should be called by StructureManager()->RecomputeStructures() after view being removed.
Dear kgv, You're right, the view should be Nullified before calling RecomputeStructures().
Branch [archived branch] has been created by Commenter 1.
[revision removed]
Detailed log of new commits:
Author: Commenter 1
Date: Sun Jul 9 10:48:23 2017 +0300
V3d_View::Remove() - erase trihedron and grid structures from structure manager
Author: Commenter 1
Date: Sun Jul 9 10:48:23 2017 +0300
0028889: Visualization, V3d_View - View specific Graphic3d_Structure should be removed if the view is removed
Cosmetics.
[revision removed]
Detailed log of new commits:
Author: Commenter 1
Date: Sun Jul 9 10:48:23 2017 +0300
V3d_View::Remove() - erase trihedron and grid structures from structure manager
Author: Commenter 1
Date: Sun Jul 9 10:48:23 2017 +0300
0028889: Visualization, V3d_View - View specific Graphic3d_Structure should be removed if the view is removed
Cosmetics.
Branch [archived branch] has been created by Commenter 1.
[revision removed]
Detailed log of new commits:
Author: Commenter 1
Date: Mon Jul 10 08:54:15 2017 +0300
0028889: Visualization, V3d_View - View specific Graphic3d_Structure should be removed if the view is removed
V3d_View::Remove() - erase trihedron and grid structures from structure manager.
[revision removed]
Detailed log of new commits:
Author: Commenter 1
Date: Mon Jul 10 08:54:15 2017 +0300
0028889: Visualization, V3d_View - View specific Graphic3d_Structure should be removed if the view is removed
V3d_View::Remove() - erase trihedron and grid structures from structure manager.
Please take the patch.
CR28889-master-KGV-Products-Debian70-64-opt-tests-compare-linux - Build # 1 - Successful:
Check console output at http://jenkins-test-10.nnov.opencascade.com:8080/job/CR28889-master-KGV-Products-Debian70-64-opt-tests-compare-linux/1/ to view the results.
CR28889-master-KGV-Products-Windows-64-VC10-opt-tests-compare-windows - Build # 1 - Successful:
Check console output at http://jenkins-test-10.nnov.opencascade.com:8080/job/CR28889-master-KGV-Products-Windows-64-VC10-opt-tests-compare-windows/1/ to view the results.
CR28889-master-KGV-Products-Debian70-64-opt-tests-compare-linux - Build # 1 - Successful:
Check console output at http://jenkins-test-10.nnov.opencascade.com:8080/job/CR28889-master-KGV-Products-Debian70-64-opt-tests-compare-linux/1/ to view the results.
CR28889-master-KGV-Products-Windows-64-VC10-opt-tests-compare-windows - Build # 1 - Successful:
Check console output at http://jenkins-test-10.nnov.opencascade.com:8080/job/CR28889-master-KGV-Products-Windows-64-VC10-opt-tests-compare-windows/1/ to view the results.
Dear Commenter 2,
Branch CR28889 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested on Release mode.
[revision removed]
Number of compiler warnings:
occt component :
Linux: 0 (0 on master)
Windows: 0 (0 on master)
MacOS : 0 (0 on master)
products component :
Linux: 64 (64 on master)
Windows: 0 (0 on master)
MacOS : 1150
Regressions/Differences/Improvements:
No regressions/differences
Testing cases:
Not needed
Testing on Linux:
occt component :
Total CPU difference: 19340.849999999904 / 19289.600000000315 [+0.27%]
Total MEMORY difference: 92451359 / 91871495 [+0.63%]
products component :
Total CPU difference: 6496.0000000000755 / 6487.850000000069 [+0.13%]
Total MEMORY difference: 37582090 / 37650261 [-0.18%]
Testing on Windows:
occt component :
Total CPU difference: 17880.195015898556 / 17783.926798798613 [+0.54%]
Total MEMORY difference: 59026034 / 59027676 [-0.00%]
products component :
Total CPU difference: 6694.377312400081 / 6584.849010300061 [+1.66%]
Total MEMORY difference: 27838712 / 28099545 [-0.93%]
There are no differences in images found by testdiff.
Branch CR28889 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested on Release mode.
[revision removed]
Number of compiler warnings:
occt component :
Linux: 0 (0 on master)
Windows: 0 (0 on master)
MacOS : 0 (0 on master)
products component :
Linux: 64 (64 on master)
Windows: 0 (0 on master)
MacOS : 1150
Regressions/Differences/Improvements:
No regressions/differences
Testing cases:
Not needed
Testing on Linux:
occt component :
Total CPU difference: 19340.849999999904 / 19289.600000000315 [+0.27%]
Total MEMORY difference: 92451359 / 91871495 [+0.63%]
products component :
Total CPU difference: 6496.0000000000755 / 6487.850000000069 [+0.13%]
Total MEMORY difference: 37582090 / 37650261 [-0.18%]
Testing on Windows:
occt component :
Total CPU difference: 17880.195015898556 / 17783.926798798613 [+0.54%]
Total MEMORY difference: 59026034 / 59027676 [-0.00%]
products component :
Total CPU difference: 6694.377312400081 / 6584.849010300061 [+1.66%]
Total MEMORY difference: 27838712 / 28099545 [-0.93%]
There are no differences in images found by testdiff.
Dear Commenter 2,
Branch CR28889 from occt git-repository is TESTED.
Branch CR28889 from occt git-repository is TESTED.
Branch [archived branch] has been deleted by Commenter 1.
[revision removed]
[revision removed]
Branch [archived branch] has been deleted by Commenter 1.
[revision removed]
[revision removed]
Related records