View Issue Details

IDProjectCategoryView StatusLast Update
0026249Open CASCADEOCCT:Visualizationpublic2015-10-23 20:51
Reporterkgv Assigned Tobugmaster  
PrioritynormalSeveritycrash 
Status closedResolutionfixed 
PlatformWindowsOSVC++ 2013 
Product Version6.9.0 
Target Version6.9.1Fixed in Version6.9.1 
Summary0026249: Visualization, TKV3d - fix possible division by zero in SelectMgr_RectangularFrustum
DescriptionChaotic mouse movements and rotations in MFC sample with RCCarSuspension.stp model in shaded mode produces the following crash:
First-chance exception at 0x000007FED3956DF7 (TKV3d.dll) in ImportExport.exe: 0xC000008E: Floating-point division by zero (parameters: 0x0000000000000000, 0x0000000000001936).

at the following line (aTriangleNormal is zero vector):
    SelectMgr_Vec3 anEdge = (aPnt1 - myNearPickedPnt) * (1.0 / DOT (aTriangleNormal, myViewRayDir));


Call stack:
TKV3d.dll!SelectMgr_RectangularFrustum::Overlaps(const gp_Pnt & thePnt1={...}, const gp_Pnt & thePnt2={...}, const gp_Pnt & thePnt3={...}, Select3D_TypeOfSensitivity theSensType=Select3D_TOS_INTERIOR, double & theDepth=0.00000000000000000) Line 716	C++
TKV3d.dll!SelectMgr_SelectingVolumeManager::Overlaps(const gp_Pnt & thePt1={...}, const gp_Pnt & thePt2={...}, const gp_Pnt & thePt3={...}, int theSensType=0, double & theDepth=0.00000000000000000) Line 292	C++
TKV3d.dll!Select3D_SensitiveTriangulation::overlapsElement(SelectBasics_SelectingVolumeManager & theMgr={...}, int theElemIdx=9, double & theMatchDepth=0.00000000000000000) Line 299	C++
TKV3d.dll!Select3D_SensitiveSet::Matches(SelectBasics_SelectingVolumeManager & theMgr={...}, SelectBasics_PickResult & thePickResult={...}) Line 132	C++
     TKV3d.dll!SelectMgr_ViewerSelector::checkOverlap(const Handle_SelectBasics_SensitiveEntity & theEntity={...}, const int theEntityIdx=1834, SelectMgr_SelectingVolumeManager & theMgr={...}) Line 250	C++
TKV3d.dll!SelectMgr_ViewerSelector::traverseObject(const Handle_SelectMgr_SelectableObject & theObject={...}) Line 370	C++
TKV3d.dll!SelectMgr_ViewerSelector::TraverseSensitives() Line 449	C++
TKV3d.dll!StdSelect_ViewerSelector3d::Pick(const int theXPix=364, const int theYPix=141, const Handle_V3d_View & theView={...}) Line 135	C++
TKV3d.dll!AIS_InteractiveContext::MoveTo(const int theXPix=364, const int theYPix=141, const Handle_V3d_View & theView={...}, const unsigned int theToRedrawOnUpdate=1) Line 81	C++
mfcsample.dll!OCC_3dBaseDoc::MoveEvent(const int theMouseX=364, const int theMouseY=141, const Handle_V3d_View & theView={...}) Line 142	C++
mfcsample.dll!OCC_3dView::OnMouseMove(unsigned int nFlags=8, CPoint point={...}) Line 508	C++

locals:
+aPnt1	[-8.7599999999999874 16.574999999999999 33.273326932224485]	NCollection_Vec3<double>
 aTime	-9.2559631349317831e+061	double
 aV	-9.2559631349317831e+061	double
+aTriangleNormal	[0.00000000000000000 0.00000000000000000 0.00000000000000000]	NCollection_Vec3<double>
 anU	-9.2559631349317831e+061	double
 aNearestEdgeIdx	-858993460	int
+anEdge	[-9.2559631349317831e+061 -9.2559631349317831e+061 -9.2559631349317831e+061]	NCollection_Vec3<double>
+aPtOnPlane	[-9.2559631349317831e+061 -9.2559631349317831e+061 -9.2559631349317831e+061]	NCollection_Vec3<double>
 aMinDist	-9.2559631349317831e+061	double
 isInterior	3435973836	unsigned int
+aPnts	0x00000000001fce00 {[-1.#INF0000 -1.#INF0000 -1.#INF0000], [-1.#INF0000 -1.#INF0000 -1.#INF0000], [-1.#INF0000 -1.#INF0000 -1.#INF0000]}	gp_Pnt[3]
+aVec	[-9.2559631349317831e+061 -9.2559631349317831e+061 -9.2559631349317831e+061]	NCollection_Vec3<double>
+aTrEdges	0x00000000001fccc0 {[0.98957142910224949 0.67458083202624053 0.69145038675820558], [-0.98957142910224949 -0.67458083202624053 -0.69145038675820558], ...}	NCollection_Vec3<double>[3]
+this	0x00000000047b16a0 {myNearPickedPnt=[-27.749121776852334 65.945000536628626 86.782194567214262] myFarPickedPnt=...}	SelectMgr_RectangularFrustum *
+thePnt1	[-8.76000023 16.5750008 33.2733269]	const gp_Pnt &
+thePnt2	[-7.77042866 17.2495804 33.9647789]	const gp_Pnt &
+thePnt3	[-8.76000023 16.5750008 33.2733269]	const gp_Pnt &
 theSensType	Select3D_TOS_INTERIOR (0)	Select3D_TypeOfSensitivity
 theDepth	0.00000000000000000	double &
Steps To ReproduceN/A
TagsNo tags attached.
Test case numberNot needed

Activities

git

2015-07-31 16:44

administrator   ~0043762

Branch CR26249 has been created by vpa.

SHA-1: 9ecc27b0b6eb9bcf51c32ef8a735c079a424c66c


Detailed log of new commits:

Author: vpa
Date: Fri Jul 31 16:43:47 2015 +0300

    0026249: Visualization, TKV3d - fix possible division by zero in SelectMgr_RectangularFrustum
    
    Added zero-length check for triangle normal in SelectMgr_RectangularFrustum::Overlaps

vpa

2015-07-31 16:47

developer   ~0043763

Dear Kirill,

please review patch in branch CR26249.

git

2015-07-31 16:50

administrator   ~0043764

Branch CR26249 has been updated forcibly by vpa.

SHA-1: 1505c3b3eda82cb1ec129e04f13e294a9b9868e6

kgv

2015-08-03 17:33

developer   ~0043794

Last edited: 2015-08-03 17:34

Can not be DOT (aTriangleNormal, myViewRayDir) itself zero even if aTriangleNormal is not zero? I think zero check could be set a little bit later for safety.

git

2015-08-03 18:43

administrator   ~0043796

Branch CR26249 has been updated forcibly by vpa.

SHA-1: bb58fb75be9a998e2e9d00e2fd1dd6c82edabba2

vpa

2015-08-03 18:49

developer   ~0043797

Yes, DOT (aTriangleNormal, myViewRayDir) can be equal to zero even triangle normal is not a zero-length vector. This would mean that selection frustum's direction is orthogonal to triangle's normal, but they do overlap.

I have updated the code in CR26249 according to your remark. Please, review.

kgv

2015-08-03 19:05

developer   ~0043798

Please test the patch.

mkv

2015-08-04 17:27

tester   ~0043818

Dear BugMaster,
Branch CR26249 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: bb58fb75be9a998e2e9d00e2fd1dd6c82edabba2

Number of compiler warnings:

occt component :
Linux: 15 (15 on master)
Windows: 0 (0 on master)

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

Regressions/Differences/Improvements:
No regressions/differences

Testing cases:
Not needed

Testing on Linux:
occt component :
Total MEMORY difference: 92274874 / 91605301 [+0.73%]
Total CPU difference: 18007.7099999991 / 18131.739999999096 [-0.68%]
products component :
Total MEMORY difference: 24843617 / 24843720 [-0.00%]
Total CPU difference: 6947.210000000005 / 6151.349999999959 [+12.94%]

Testing on Windows:
occt component :
Total MEMORY difference: 57610736 / 57633878 [-0.04%]
Total CPU difference: 16247.30134869904 / 16352.040420099176 [-0.64%]
products component :
Total MEMORY difference: 16004845 / 16012079 [-0.05%]
Total CPU difference: 5296.155949499965 / 5281.92865829996 [+0.27%]

There are no differences in images found by testdiff.

git

2015-08-14 10:52

administrator   ~0044130

Branch CR26249 has been deleted by inv.

SHA-1: bb58fb75be9a998e2e9d00e2fd1dd6c82edabba2

Related Changesets

occt: master 7e17e8f0

2015-08-03 15:41:56

vpa


Committer: bugmaster Details Diff
0026249: Visualization, TKV3d - fix possible division by zero in SelectMgr_RectangularFrustum

Added zero-length check for triangle normal in SelectMgr_RectangularFrustum::Overlaps
Affected Issues
0026249
mod - src/SelectMgr/SelectMgr_RectangularFrustum.cxx Diff File

Issue History

Date Modified Username Field Change
2015-05-21 11:23 kgv New Issue
2015-05-21 11:23 kgv Assigned To => kgv
2015-05-21 11:25 kgv Assigned To kgv => vpa
2015-05-21 11:25 kgv Status new => assigned
2015-05-21 11:25 kgv Description Updated
2015-07-31 16:44 git Note Added: 0043762
2015-07-31 16:47 vpa Note Added: 0043763
2015-07-31 16:47 vpa Assigned To vpa => kgv
2015-07-31 16:47 vpa Status assigned => resolved
2015-07-31 16:47 vpa Steps to Reproduce Updated
2015-07-31 16:50 git Note Added: 0043764
2015-08-03 17:33 kgv Note Added: 0043794
2015-08-03 17:33 kgv Assigned To kgv => vpa
2015-08-03 17:33 kgv Status resolved => assigned
2015-08-03 17:34 kgv Note Edited: 0043794
2015-08-03 18:43 git Note Added: 0043796
2015-08-03 18:49 vpa Note Added: 0043797
2015-08-03 18:49 vpa Assigned To vpa => kgv
2015-08-03 18:49 vpa Status assigned => resolved
2015-08-03 19:05 kgv Note Added: 0043798
2015-08-03 19:05 kgv Assigned To kgv => bugmaster
2015-08-03 19:05 kgv Status resolved => reviewed
2015-08-03 20:13 mkv Assigned To bugmaster => mkv
2015-08-04 17:27 mkv Note Added: 0043818
2015-08-04 17:27 mkv Assigned To mkv => bugmaster
2015-08-04 17:27 mkv Status reviewed => tested
2015-08-04 17:28 mkv Test case number => Not needed
2015-08-07 16:01 bugmaster Changeset attached => occt master 7e17e8f0
2015-08-07 16:01 bugmaster Status tested => verified
2015-08-07 16:01 bugmaster Resolution open => fixed
2015-08-14 10:52 git Note Added: 0044130
2015-08-26 11:11 abv Target Version 7.0.0 => 6.9.1
2015-10-16 14:56 aiv Status verified => closed
2015-10-23 20:51 aiv Fixed in Version => 6.9.1