MantisBT - Community
View Issue Details
0028889Community[OCCT] OCCT:Visualizationpublic2017-07-04 12:412017-09-29 16:28
Vico Liang 
kgv 
normalminor 
closedfixed 
WindowsVC++ 201364 bit
[OCCT] 7.1.0 
[OCCT] 7.2.0[OCCT] 7.2.0 
Not needed
0028889: Visualization, V3d_View - View specific Graphic3d_Structure should be removed if the view is removed
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(); }

N/A
No tags attached.
parent of 0028927closed bugmaster Open CASCADE Visualization - Graphic3d_StructureManager destructor should invalidate its pointer in Graphic3d_Structure 
Issue History
2017-07-04 12:41Vico LiangNew Issue
2017-07-04 12:41Vico LiangAssigned To => kgv
2017-07-04 12:45Vico LiangDescription Updatedbug_revision_view_page.php?rev_id=17024#r17024
2017-07-07 15:05kgvNote Added: 0068089
2017-07-07 15:05kgvAssigned Tokgv => Vico Liang
2017-07-07 15:05kgvStatusnew => feedback
2017-07-08 20:27Vico LiangNote Added: 0068105
2017-07-08 20:27Vico LiangAssigned ToVico Liang => kgv
2017-07-08 20:27Vico LiangStatusfeedback => assigned
2017-07-08 20:29Vico LiangNote Added: 0068106
2017-07-08 20:32kgvNote Added: 0068107
2017-07-08 20:40Vico LiangNote Added: 0068108
2017-07-08 20:43Vico LiangNote Added: 0068109
2017-07-09 10:38kgvSummaryView specific Graphic3d_Structure should be removed if the view is removed => Visualization, V3d_View - View specific Graphic3d_Structure should be removed if the view is removed
2017-07-09 11:04gitNote Added: 0068110
2017-07-10 08:54gitNote Added: 0068113
2017-07-10 08:55kgvNote Added: 0068114
2017-07-10 08:55kgvAssigned Tokgv => bugmaster
2017-07-10 08:55kgvSeveritycrash => minor
2017-07-10 08:55kgvStatusassigned => resolved
2017-07-10 08:55kgvStatusresolved => reviewed
2017-07-10 08:55kgvSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=17053#r17053
2017-07-10 12:25mkvNote Added: 0068151
2017-07-10 12:26mkvNote Added: 0068152
2017-07-10 12:26mkvStatusreviewed => tested
2017-07-10 12:26mkvTest case number => Not needed
2017-07-14 13:55kgvChangeset attached => occt master 475c2302
2017-07-14 13:55kgvAssigned Tobugmaster => kgv
2017-07-14 13:55kgvStatustested => verified
2017-07-14 13:55kgvResolutionopen => fixed
2017-07-17 10:05gitNote Added: 0068346
2017-07-17 10:05gitNote Added: 0068347
2017-07-19 17:41kgvRelationship addedparent of 0028927
2017-09-29 16:18aivFixed in Version => 7.2.0
2017-09-29 16:28aivStatusverified => closed

Notes
(0068089)
kgv   
2017-07-07 15:05   
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.
(0068105)
Vico Liang   
2017-07-08 20:27   
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.
(0068106)
Vico Liang   
2017-07-08 20:29   
Below compute method will access the dangling pointer myTrihedron:
 class V3d_Trihedron::TrihedronStructure
   virtual void Compute() Standard_OVERRIDE { myTrihedron->compute(); }
(0068107)
kgv   
2017-07-08 20:32   
OK, so the test code in the bug description should include NULLifying view before calling RecomputeStructures().
(0068108)
Vico Liang   
2017-07-08 20:40   
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.
(0068109)
Vico Liang   
2017-07-08 20:43   
Dear kgv, You're right, the view should be Nullified before calling RecomputeStructures().
(0068110)
git   
2017-07-09 11:04   
Branch CR28889 has been created by kgv.

SHA-1: 1a7ea872ddc82b346b7952c334ef4e99237890da


Detailed log of new commits:

Author: kgv
Date: Sun Jul 9 10:48:23 2017 +0300

    V3d_View::Remove() - erase trihedron and grid structures from structure manager

Author: kgv
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.
(0068113)
git   
2017-07-10 08:54   
Branch CR28889_1 has been created by kgv.

SHA-1: 475c2302d4e46524e9934d612174ee4da790d28a


Detailed log of new commits:

Author: kgv
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.
(0068114)
kgv   
2017-07-10 08:55   
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.
(0068151)
mkv   
2017-07-10 12:25   
Dear BugMaster,
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.
SHA-1: 1a7ea872ddc82b346b7952c334ef4e99237890da

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.
(0068152)
mkv   
2017-07-10 12:26   
Dear BugMaster,
Branch CR28889 from occt git-repository is TESTED.
(0068346)
git   
2017-07-17 10:05   
Branch CR28889 has been deleted by kgv.

SHA-1: 1a7ea872ddc82b346b7952c334ef4e99237890da
(0068347)
git   
2017-07-17 10:05   
Branch CR28889_1 has been deleted by kgv.

SHA-1: 475c2302d4e46524e9934d612174ee4da790d28a