MantisBT - Open CASCADE
View Issue Details
0022554Open CASCADE[OCCT] OCCT:Visualizationpublic2011-05-31 15:012012-03-29 17:26
kgv 
bugmaster 
normaltrivial 
closedfixed 
All
[OCCT] 6.5.0 
[OCCT] 6.5.3[OCCT] 6.5.3 
Test cases chl 934 T7 T8 T9 U1
0022554: Application hangs on selection
In method Standard_Real Select3D_SensitiveCurve::ComputeDepth(),
(Select3D_Pnt*)mypolyg3d accessed without out-of-range check (mylastseg+1 can
be equal to mynbpoints).
If happens - this cause undefined behaviour or even application hang (if
values interpreted as QNAN).

In class Select3D_SensitivePoly fields mypolyg3d and mypolyg2d declared and
managed in unsafe manner. This cause potential errors in other places where
these arrays are used.
Added entities:

Select3D_PointData.hxx – implemented class Select3D_PointData for safe management of Select3D_SensitivePoly polygons of 3D and 2D points.

Modified entities:

Select3D_SensitivePoly.cdl :
Added new member Select3D_PointData mypolyg instead of members mypolyg3d, mypolyg2d, mynbpoints. Removed method Destroy().

Modified all methods that used old members mypolyg3d, mypolyg2d, mynbpoints in the following files:
Select3D_SensitiveCircle.cxx
Select3D_SensitiveCurve.cxx
Select3D_SensitiveFace.cxx
Select3D_SensitivePoly.cxx
Select3D_SensitivePoly.lxx
Select3D_SensitiveTriangle.cxx


ViewerTest_ObjectCommands.cxx:

Added two new classes Triangle and SegmentObject based on AIS_InteractiveObject.
Added two new DRAW commands vtriangle and vsegment. All of them – for test Select3D_SensitiveTriangle and Select3D_SensitiveCurve.
 
thug.doc :

Added description of new DRAW commands vtriangle and vsegment.
No tags attached.
related to 0012121closed bugmaster Optimization of existing selection classes 
? vcircle.tcl (120) 2012-02-03 11:56
https://tracker.dev.opencascade.org/
? vplane.tcl (118) 2012-02-03 11:57
https://tracker.dev.opencascade.org/
? vsegment.tcl (95) 2012-02-03 11:57
https://tracker.dev.opencascade.org/
? vtriangle.tcl (123) 2012-02-03 11:57
https://tracker.dev.opencascade.org/
gz chl_934_T7_T8_T9_U1.tar.gz (453) 2012-02-22 17:16
https://tracker.dev.opencascade.org/
Issue History
2011-08-02 11:24bugmasterCategoryOCCT:VIZ => OCCT:Visualization
2011-10-07 17:28sanAssigned Tobugmaster => aaa
2011-10-07 17:28sanStatusnew => assigned
2012-02-01 16:40sanRelationship addedrelated to 0012121
2012-02-01 16:42sanNote Added: 0019333
2012-02-01 16:42sanNote Edited: 0019333bug_revision_view_page.php?bugnote_id=19333#r3354
2012-02-03 11:31aaaFixed in VersionEMPTY =>
2012-02-03 11:31aaaDescription Updatedbug_revision_view_page.php?rev_id=3369#r3369
2012-02-03 11:31aaaAdditional Information Updatedbug_revision_view_page.php?rev_id=3371#r3371
2012-02-03 11:32aaaAssigned Toaaa => san
2012-02-03 11:33aaaNote Added: 0019371
2012-02-03 11:33aaaStatusassigned => feedback
2012-02-03 11:33aaaAssigned Tosan => aaa
2012-02-03 11:34aaaNote Deleted: 0019371
2012-02-03 11:34aaaNote Added: 0019372
2012-02-03 11:34aaaAssigned Toaaa => san
2012-02-03 11:34aaaStatusfeedback => resolved
2012-02-03 11:56aaaFile Added: vcircle.tcl
2012-02-03 11:57aaaFile Added: vplane.tcl
2012-02-03 11:57aaaFile Added: vsegment.tcl
2012-02-03 11:57aaaFile Added: vtriangle.tcl
2012-02-03 12:00aaaNote Added: 0019373
2012-02-03 16:35abvRelationship addedrelated to 0022819
2012-02-03 17:46kgvNote Added: 0019392
2012-02-03 18:02kgvNote Edited: 0019392bug_revision_view_page.php?bugnote_id=19392#r3380
2012-02-03 18:03kgvNote Edited: 0019392bug_revision_view_page.php?bugnote_id=19392#r3381
2012-02-06 17:57sanAssigned Tosan => aaa
2012-02-07 11:44aaaAdditional Information Updatedbug_revision_view_page.php?rev_id=3391#r3391
2012-02-07 11:44aaaAdditional Information Updatedbug_revision_view_page.php?rev_id=3392#r3392
2012-02-07 11:45aaaNote Added: 0019424
2012-02-07 11:45aaaAssigned Toaaa => san
2012-02-07 11:45aaaStatusresolved => assigned
2012-02-07 11:56sanStatusassigned => resolved
2012-02-07 12:08abvProduct Version => 6.5.0
2012-02-07 12:08abvTarget Version => 6.5.3
2012-02-08 14:47sanNote Added: 0019460
2012-02-08 14:47sanAssigned Tosan => aaa
2012-02-08 14:47sanStatusresolved => assigned
2012-02-10 11:32dlnRelationship deletedrelated to 0022819
2012-02-10 14:49aaaNote Added: 0019508
2012-02-10 14:49aaaAssigned Toaaa => san
2012-02-10 14:49aaaStatusassigned => resolved
2012-02-20 13:16sanNote Added: 0019664
2012-02-20 13:16sanAssigned Tosan => bugmaster
2012-02-20 13:16sanStatusresolved => reviewed
2012-02-20 14:25mkvAssigned Tobugmaster => mkv
2012-02-21 19:52mkvNote Added: 0019708
2012-02-22 15:02mkvStatusreviewed => tested
2012-02-22 17:06bugmasterNote Added: 0019745
2012-02-22 17:06bugmasterStatustested => verified
2012-02-22 17:06bugmasterResolutionopen => fixed
2012-02-22 17:16mkvFile Added: chl_934_T7_T8_T9_U1.tar.gz
2012-02-22 17:17mkvTest case number => Test cases chl 934 T7 T8 T9 U1
2012-03-29 17:26bugmasterChangeset attached => occt master ceae62f0

Notes
(0019333)
san   
2012-02-01 16:42   
This issue was suspended till integration of the patch for 0012121.
Now that the patch is in the trunk, this issue has been unblocked, so please proceed with its correction.

(0019372)
aaa   
2012-02-03 11:34   
SVN branch http://svn/svn/occt/branches/OCC22554 [^] is ready for reviewing
(0019373)
aaa   
2012-02-03 12:00   
Files added :
vcircle.tcl
vplane.tcl
vsegment.tcl
vtriangle.tcl

Test scripts display circle, plane, segment and triangle. Selection and highlighting for these objects should work as usual.
(0019392)
kgv   
2012-02-03 17:46   
(edited on: 2012-02-03 18:03)
> Select3D_SensitivePoly(const Handle(SelectBasics_EntityOwner)& OwnerId,
> const TColgp_Array1OfPnt& ThePoints)
> : Select3D_SensitiveEntity(OwnerId),
> mypolyg(ThePoints.Upper()-ThePoints.Lower()+1)
> {
> if (!mypolyg.IsValid())
> return;
This validation is performed in all constructors and class methods!
And looks like checking (this != NULL).
There are 2 questions:
- is this solution has benefits against behavior used in OCCT to throw exception in constructor when incorrect data is passed?
- is it really happens (if not - then it is better to throw exception to indicate really invalid situation)?

Comments in new header file 'Select3D_PointData.hxx' doesn't corresponds to OCCT coding rules. This is also bad practice to clarify class with constructor and destructor with 'struct' keyword.

Select3D_SensitivePoly.lxx, 6
> inline void Select3D_SensitivePoly
> ::Points3D( Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt )
> {
> Standard_Integer aSize = mypolyg.Size();
> theHArrayOfPnt = new TColgp_HArray1OfPnt(1,aSize);
> for(Standard_Integer i = 1; i <= aSize; i++)
> {
> gp_Pnt aPnt;
>> if(mypolyg.Pnt(i-1, aPnt)) /// ????
> theHArrayOfPnt->SetValue(i, aPnt);
> }
> }
how this condition may fail if cycle limited to mypolyg.Size()?

(0019424)
aaa   
2012-02-07 11:45   
SVN branch http://svn/svn/occt/branches/OCC22554 [^] is ready for reviewing
(0019460)
san   
2012-02-08 14:47   
The branch reviewed with the following remarks:

Select3D_SensitiveCircle class
====================================
Standard_Boolean Select3D_SensitiveCircle::
Matches(const Standard_Real X,
        const Standard_Real Y,
        const Standard_Real aTol,
        Standard_Real& DMin)

The case when mypolyg.Size() == 1 (a circle degenerated down to a point) is not treated, though it is possible according to constructors.
Corresponding code to be added similalry to Select3D_SensitivePoint::Matches().

In general, please check that Matches() methods do not return Standard_True when something wrong happens.
Otherwise, myDetectedIndex might be invalid but ComputeDepth() will be called that uses it.

ComputeDepth() should return Precision::Infinite() if something goes wrong - see Select3D_SensitiveCurve::ComputeDepth().

(0019508)
aaa   
2012-02-10 14:49   
SVN branch http://svn/svn/occt/branches/OCC22554 [^] is ready for reviewing
(0019664)
san   
2012-02-20 13:16   
The branch OCC22554 reviewed without remarks and is ready for testing.
(0019708)
mkv   
2012-02-21 19:52   
Dear BugMaster,
Workbench KAS:dev:mkv-22554-occt was created from SVN branch http://svn/svn/occt/branches/OCC22554 [^]
(and mkv-22554-products from trunk) and compiled on Linux platform.

There are not regressions in mkv-22554-products regarding to KAS:dev:products-20120217-opt

See results in /QADisk/occttests/results/KAS/dev/mkv-22554-products_20022012/lin
See reference results in /QADisk/occttests/results/KAS/dev/products-20120217-opt_17022012/lin
See test cases in /QADisk/occttests/tests/ED
N.B. In order to launch testing case you can make use the following instructions
http://doc/doku.php?id=occt:certification [^]
(0019745)
bugmaster   
2012-02-22 17:06   
Integrated into trunk of occt repository

Date: 2012-02-22 17:01:33 +0400 (Wed, 22 Feb 2012)
New Revision: 10603

Added:
   trunk/src/Select3D/Select3D_PointData.hxx
Modified:
   trunk/src/Select3D/FILES
   trunk/src/Select3D/Select3D.cdl
   trunk/src/Select3D/Select3D_SensitiveCircle.cdl
   trunk/src/Select3D/Select3D_SensitiveCircle.cxx
   trunk/src/Select3D/Select3D_SensitiveCurve.cdl
   trunk/src/Select3D/Select3D_SensitiveCurve.cxx
   trunk/src/Select3D/Select3D_SensitiveFace.cdl
   trunk/src/Select3D/Select3D_SensitiveFace.cxx
   trunk/src/Select3D/Select3D_SensitivePoly.cdl
   trunk/src/Select3D/Select3D_SensitivePoly.cxx
   trunk/src/Select3D/Select3D_SensitivePoly.lxx
   trunk/src/Select3D/Select3D_SensitiveTriangle.cdl
   trunk/src/Select3D/Select3D_SensitiveTriangle.cxx
   trunk/src/ViewerTest/ViewerTest_ObjectCommands.cxx