MantisBT - Community
View Issue Details
0027357Community[OCCT] OCCT:Modeling Algorithmspublic2016-04-05 20:422016-12-09 16:38
sraymond 
bugmaster 
lowcrash 
closedreopened 
WindowsVC++ 201564 bit
[OCCT] 7.0.0 
[OCCT] 7.1.0[OCCT] 7.1.0 
bugs modalg_6 bug27357
0027357: Geom2dGcc_Circ2d2TanOn: check status of sub-algorithms to avoid exceptions
When Geom2dGcc_Circ2d2TanOn is used in a loop it crash after a while when it's destroyed.

This bug was reported here too.

I don't get it with my mac version, the phenomena can't be reproduced with OC compiled with debug options.

http://www.opencascade.com/content/bug-geom2dgcccirc2d2tanradgeo-geom2dgcccirc2d2tanrad [^]
Here is an example showing how it crashes :

    TColgp_Array1OfPnt2d poles(1,3);
    poles.SetValue(1,gp_Pnt2d(0.,0.));
    poles.SetValue(2,gp_Pnt2d(0.,1.));
    poles.SetValue(3,gp_Pnt2d(6.,0.));

    Handle(Geom2d_BezierCurve) curve1 = new Geom2d_BezierCurve(poles);

    poles.SetValue(2,gp_Pnt2d(0.,1.5));

    Handle(Geom2d_BezierCurve) curve2 = new Geom2d_BezierCurve(poles);

    int nP = 100;
    int nFailed=0;
    for(int i = 0 ; i < nP ; i++){
        double u = i / (nP-1.);
        gp_Pnt2d p1;
        gp_Vec2d tangent;
        curve1->D1(u,p1,tangent);
        gp_Vec2d normal(-tangent.Y(),tangent.X());
        Handle(Geom2d_Line) normalLine=new Geom2d_Line(p1,gp_Dir2d(normal));


        Geom2dGcc_QualifiedCurve qualifiedC1(Geom2dAdaptor_Curve(curve1),GccEnt_unqualified);
        Geom2dGcc_QualifiedCurve qualifiedC2(Geom2dAdaptor_Curve(curve2),GccEnt_unqualified);

        try{
            Geom2dAPI_ProjectPointOnCurve projPc1(p1, curve1);
            double guess1 = projPc1.LowerDistanceParameter();
            Geom2dAPI_ProjectPointOnCurve projPc3(p1, normalLine);
            double guess3 = projPc3.LowerDistanceParameter();
            Geom2dGcc_Circ2d2TanOn circleBuilder(qualifiedC1,qualifiedC2,Geom2dAdaptor_Curve(normalLine),1e-9,guess1,guess1,guess3);
            int nSol = circleBuilder.NbSolutions();
            if (nSol > 0){
                gp_Circ2d circle = circleBuilder.ThisSolution(1);
                gp_Pnt2d center=circle.Location();
            }
        }
        catch(Standard_Failure){
            nFailed++;
        }
    }
No tags attached.
Issue History
2016-04-05 20:42sraymondNew Issue
2016-04-05 20:42sraymondAssigned To => msv
2016-04-07 11:07msvNote Added: 0052459
2016-04-07 14:46sraymondNote Added: 0052470
2016-04-07 15:33abvStatusnew => closed
2016-04-07 15:33abvResolutionopen => no change required
2016-04-07 15:33abvTarget Version7.1.0 =>
2016-04-07 18:59msvNote Added: 0052486
2016-04-07 18:59msvStatusclosed => feedback
2016-04-07 18:59msvResolutionno change required => reopened
2016-05-19 10:09msvPrioritynormal => low
2016-05-19 10:09msvStatusfeedback => assigned
2016-05-19 10:09msvSummaryGeom2dGcc_Circ2d2TanOn crash in a loop => Geom2dGcc_Circ2d2TanOn: check status of sub-algorithms to avoid exceptions
2016-06-09 18:09msvAssigned Tomsv => isn
2016-06-17 14:51gitNote Added: 0055176
2016-06-17 14:55isnNote Added: 0055178
2016-06-17 14:55isnAssigned Toisn => msv
2016-06-17 14:55isnStatusassigned => feedback
2016-06-20 11:16gitNote Added: 0055205
2016-06-20 11:51msvNote Added: 0055213
2016-06-20 11:51msvAssigned Tomsv => isn
2016-06-20 11:51msvStatusfeedback => assigned
2016-06-20 17:14gitNote Added: 0055247
2016-06-20 17:15isnAssigned Toisn => msv
2016-06-20 17:15isnStatusassigned => resolved
2016-06-21 10:02msvNote Edited: 0055213bug_revision_view_page.php?bugnote_id=55213#r14022
2016-06-21 10:08msvNote Added: 0055279
2016-06-21 10:08msvAssigned Tomsv => bugmaster
2016-06-21 10:08msvStatusresolved => reviewed
2016-06-21 10:09msvTarget Version => 7.1.0
2016-06-21 11:44apvAssigned Tobugmaster => apv
2016-06-21 18:11gitNote Added: 0055317
2016-06-21 18:12apvNote Added: 0055318
2016-06-22 13:14apvTest case number => bugs modalg_6 bug27357
2016-06-22 13:18apvNote Added: 0055338
2016-06-22 13:18apvAssigned Toapv => isn
2016-06-22 13:18apvStatusreviewed => assigned
2016-06-22 13:19apvNote Added: 0055339
2016-06-22 18:58gitNote Added: 0055354
2016-06-22 18:59isnAssigned Toisn => msv
2016-06-22 18:59isnStatusassigned => resolved
2016-06-23 09:59msvNote Added: 0055360
2016-06-23 09:59msvAssigned Tomsv => isn
2016-06-23 09:59msvStatusresolved => assigned
2016-06-23 12:32gitNote Added: 0055367
2016-06-23 12:32isnNote Added: 0055368
2016-06-23 12:32isnAssigned Toisn => msv
2016-06-23 12:32isnStatusassigned => resolved
2016-06-23 12:55msvNote Added: 0055370
2016-06-23 12:55msvAssigned Tomsv => bugmaster
2016-06-23 12:55msvStatusresolved => reviewed
2016-06-23 14:16mkvAssigned Tobugmaster => apv
2016-06-23 17:51gitNote Added: 0055390
2016-06-24 13:54apvNote Added: 0055442
2016-06-24 13:54apvAssigned Toapv => bugmaster
2016-06-24 13:54apvStatusreviewed => tested
2016-07-01 17:19bugmasterChangeset attached => occt master 8009d070
2016-07-01 17:19bugmasterStatustested => verified
2016-07-22 10:45gitNote Added: 0056132
2016-12-09 16:31aivStatusverified => closed
2016-12-09 16:38aivFixed in Version => 7.1.0

Notes
(0052459)
msv   
2016-04-07 11:07   
The class Geom2dGcc_Circ2d2TanOn can throw a C++ exception of type StdFail_NotDone. This is a bug caused by the fact that the algorithm does not check the status of under-called algorithms before getting a result from them.

However, it does not crash when it is destroyed in normal situation like in the given sample. If it crashes in destructor it means there is mismatched allocation/deallocation of some memory. It can occur when you link your sample program against C run-time Multithreaded Debug DLL, but use the OCCT binary files linked against C run-time Multithreaded DLL, or vice versa. This concerns the MSVC environment on Windows.
(0052470)
sraymond   
2016-04-07 14:46   
Thanks, the example compiled in release mode doesn’t crash anymore.
(0052486)
msv   
2016-04-07 18:59   
It is needed to fix the following problem. The class Geom2dGcc_Circ2d2TanOn throws an unexpected C++ exception of type StdFail_NotDone. In fact it is raised by other algorithms called from the discussed one. It is needed to check the status of all called sub-algorithms and not to try getting result from them if their IsDone() method returns false.
(0055176)
git   
2016-06-17 14:51   
Branch CR27357 has been created by isn.

SHA-1: 0725f8081dfeaad421ee65ea8a7c6f7a16fc7091


Detailed log of new commits:

Author: isn
Date: Fri Jun 17 14:50:50 2016 +0300

    0027357: Geom2dGcc_Circ2d2TanOn: check status of sub-algorithms to avoid exceptions
    
    Additional checks for underlying algorithms have been added
(0055178)
isn   
2016-06-17 14:55   
this issue seems to be resolved, but without corrections of indentations in the Geom2dGcc_Circ2d2TanOn.cxx file.
(0055205)
git   
2016-06-20 11:16   
Branch CR27357 has been updated forcibly by isn.

SHA-1: 7f718aa8619de8d7e275c83c8e7721c14dd60395
(0055213)
msv   
2016-06-20 11:51   
(edited on: 2016-06-21 10:02)
Code correction is OK. Please create a test case that checks there is no exception. This test must fail on master.

(0055247)
git   
2016-06-20 17:14   
Branch CR27357 has been updated by isn.

SHA-1: 89d7acb8680fa1eaa54fdfe6ded6eadad977f5ed


Detailed log of new commits:

Author: isn
Date: Mon Jun 20 17:00:06 2016 +0300

    test case

(0055279)
msv   
2016-06-21 10:08   
Reviewed.
(0055317)
git   
2016-06-21 18:11   
Branch CR27357 has been updated forcibly by apv.

SHA-1: af8f8a9f57684289107ad699ceed651a952876cc
(0055318)
apv   
2016-06-21 18:12   
Branch CR27357 has been rebased on the current master
(0055338)
apv   
2016-06-22 13:18   
Dear BugMaster,

Branch CR27357 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested.
SHA-1: af8f8a9f57684289107ad699ceed651a952876cc

Number of compiler warnings:
occt component:
   Linux: 1 (0 on master)
   Windows: 0 (0 on master)
   MacOS: 1 (0 on master)
products component:
   Linux: 68
   Windows: 0
   MacOS: 1127
New warning has been detected
on Linux:
QABugs_20.cxx:2020, GNU C Compiler 4 (gcc), Priority: Normal
variable 'aCenter' set but not used [-Wunused-but-set-variable]
on MacOS:
QABugs_20.cxx:2020, Clang (LLVM based), Priority: Normal
unused variable 'aCenter'

Regressions/Differences:
Not detected

Testing cases:
bugs modalg_6 bug27357 - OK
http://occt-tests/CR27357-master-OCCT/Debian70-64/bugs/modalg_6/bug27357.html [^]
http://occt-tests/CR27357-master-OCCT/Windows-64-VC10/bugs/modalg_6/bug27357.html [^]

Testing on Linux:
Total MEMORY difference: 89269260 / 89170862 [+0.11%]
Total CPU difference: 19445.259999999897 / 19458.16999999997 [-0.07%]

Testing on Windows:
Total MEMORY difference: 55890332 / 55902024 [-0.02%]
Total CPU difference: 18078.44108669884 / 18535.508416598954 [-2.47%]
(0055339)
apv   
2016-06-22 13:19   
Dear Ilya,

Branch CR27357 has been rejected due to:
- additional warnings
(0055354)
git   
2016-06-22 18:58   
Branch CR27357 has been updated by isn.

SHA-1: 6c09b373b89105154f9b714c54f24d23c2302099


Detailed log of new commits:

Author: isn
Date: Wed Jun 22 18:40:21 2016 +0300

    get rid of the warning

(0055360)
msv   
2016-06-23 09:59   
Why did you used std::list instead of NCollection_List. I consider that in OCCT code we should use OCCT collections where it is possible. Also, please use Standard_Integer instead of int.
(0055367)
git   
2016-06-23 12:32   
Branch CR27357 has been updated forcibly by isn.

SHA-1: 7e54f27d2f8fa9a820ab0a5f4a460db5429e2271
(0055368)
isn   
2016-06-23 12:32   
ok, done
(0055370)
msv   
2016-06-23 12:55   
Reviewed. Please re-test only "bugs modalg_6 bug27357". Nothing else was changed.
(0055390)
git   
2016-06-23 17:51   
Branch CR27357 has been updated forcibly by mkv.

SHA-1: 5de21abca67c9dc0502c212d3cea81748370e55a
(0055442)
apv   
2016-06-24 13:54   
Dear BugMaster,

Branch CR27357 from occt git-repository (and IR-2016-06-23 from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested.
SHA-1: 5de21abca67c9dc0502c212d3cea81748370e55a

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
   Windows: 1
   MacOS: 1158

Regressions/Differences:
Not detected

Testing cases:
bugs modalg_6 bug27357 - OK
http://occt-tests/CR27357-master-OCCT/Debian70-64/bugs/modalg_6/bug27357.html [^]
http://occt-tests/CR27357-master-OCCT/Windows-64-VC10/bugs/modalg_6/bug27357.html [^]

Testing on Linux:
Total MEMORY difference: 88788517 / 88710130 [+0.09%]
Total CPU difference: 19512.540000000132 / 19559.77999999992 [-0.24%]

Testing on Windows:
Total MEMORY difference: 55888001 / 55896954 [-0.02%]
Total CPU difference: 18108.09687679883 / 17842.286772898675 [+1.49%]
(0056132)
git   
2016-07-22 10:45   
Branch CR27357 has been deleted by inv.

SHA-1: 5de21abca67c9dc0502c212d3cea81748370e55a