MantisBT - Community
View Issue Details
0025699Community[OCCT] OCCT:Data Exchangepublic2015-01-13 13:402015-05-14 15:32
ventu 
bugmaster 
normalcrash 
closedfixed 
AnyAnyAny
[OCCT] 6.8.0 
[OCCT] 6.9.0[OCCT] 6.9.0 
Not needed
0025699: Crash while importing STeP file
Hello.

I've got a file which crashes OpenCASCADE.
While the file is probably broken, I think a crash is not the best result in any case.

We are now running with the following patch, which avoids the crash.

--- StepToGeom_MakeBoundedCurve.cxx.bak 2014-11-07 16:16:46.000000000 +0100
+++ StepToGeom_MakeBoundedCurve.cxx 2015-01-13 11:33:03.000000000 +0100
@@ -148,6 +148,7 @@
     const Handle(StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve) RBSPL =
       new StepGeom_BSplineCurveWithKnotsAndRationalBSplineCurve;
     // Compute Knots and KnotsMultiplicity
+ if (RQUC->Degree()==0) return Standard_False;
     const Standard_Integer nbK = RQUC->NbControlPointsList() - RQUC->Degree() + 1;
     const Handle(TColStd_HArray1OfInteger) Kmult = new TColStd_HArray1OfInteger(1,nbK);
     const Handle(TColStd_HArray1OfReal) Knots = new TColStd_HArray1OfReal(1,nbK);



Of course this won't fix the original model.


Any opinion on this?
Not applicable
No tags attached.
patch step.patch (3,775) 2015-01-17 19:40
https://tracker.dev.opencascade.org/
Issue History
2015-01-13 13:40ventuNew Issue
2015-01-13 13:40ventuAssigned To => gka
2015-01-14 18:31gkaNote Added: 0036068
2015-01-16 10:22gkaAssigned Togka => ventu
2015-01-16 10:22gkaStatusnew => feedback
2015-01-16 13:23ventuNote Added: 0036141
2015-01-16 15:37gkaNote Added: 0036149
2015-01-17 19:40ventuFile Added: step.patch
2015-01-17 19:40ventuNote Added: 0036178
2015-01-27 11:11gkaAssigned Toventu => gka
2015-01-27 11:11gkaStatusfeedback => assigned
2015-01-27 11:26gkaNote Added: 0036691
2015-01-27 11:32gkaAssigned Togka => akz
2015-01-29 13:38gitNote Added: 0036812
2015-01-29 14:02akzNote Added: 0036816
2015-01-29 14:02akzAssigned Toakz => gka
2015-01-29 14:02akzStatusassigned => resolved
2015-01-29 14:02akzSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=9189#r9189
2015-01-29 14:12abvNote Added: 0036819
2015-01-29 15:05akzAssigned Togka => akz
2015-01-29 15:05akzStatusresolved => assigned
2015-01-29 15:53gitNote Added: 0036837
2015-01-29 15:54akzAssigned Toakz => gka
2015-01-29 15:54akzStatusassigned => resolved
2015-01-29 15:55akzNote Added: 0036838
2015-01-30 10:27gkaNote Added: 0036874
2015-02-03 16:38gkaAssigned Togka => akz
2015-02-03 16:38gkaStatusresolved => assigned
2015-02-09 19:16gitNote Added: 0037257
2015-02-09 19:17gitNote Added: 0037258
2015-02-09 19:17akzNote Added: 0037259
2015-02-09 19:17akzAssigned Toakz => gka
2015-02-09 19:17akzStatusassigned => resolved
2015-02-10 12:04gkaNote Added: 0037274
2015-02-10 12:04gkaAssigned Togka => bugmaster
2015-02-10 12:04gkaStatusresolved => reviewed
2015-02-10 13:01mkvAssigned Tobugmaster => apv
2015-02-12 15:41apvNote Added: 0037446
2015-02-12 15:41apvAssigned Toapv => akz
2015-02-12 15:41apvStatusreviewed => assigned
2015-02-12 15:42apvTest case number => Not needed
2015-02-12 16:36gitNote Added: 0037453
2015-02-12 16:41gitNote Added: 0037454
2015-02-12 16:46gitNote Added: 0037457
2015-02-12 16:46gitNote Added: 0037458
2015-02-12 16:51akzNote Added: 0037459
2015-02-12 16:51akzAssigned Toakz => gka
2015-02-12 16:51akzStatusassigned => resolved
2015-02-12 16:51akzNote Edited: 0037459bug_revision_view_page.php?bugnote_id=37459#r9362
2015-02-12 16:57gkaNote Added: 0037461
2015-02-12 16:57gkaAssigned Togka => bugmaster
2015-02-12 16:57gkaStatusresolved => reviewed
2015-02-12 16:59mkvAssigned Tobugmaster => apv
2015-02-13 13:09gitNote Added: 0037503
2015-02-13 13:11gitNote Added: 0037504
2015-02-13 15:55gitNote Added: 0037515
2015-02-13 17:55bugmasterChangeset attached => occt master d088c9c2
2015-02-13 17:55bugmasterAssigned Toapv => bugmaster
2015-02-13 17:55bugmasterStatusreviewed => verified
2015-02-13 17:55bugmasterResolutionopen => fixed
2015-02-13 18:25gitNote Added: 0037533
2015-02-13 18:26gitNote Added: 0037534
2015-02-13 18:27gitNote Added: 0037535
2015-02-13 18:28gitNote Added: 0037536
2015-03-10 13:00bugmasterTarget Version => 6.9.0
2015-03-18 13:35gitNote Added: 0038543
2015-03-18 13:35gitNote Added: 0038544
2015-03-18 13:35gitNote Added: 0038545
2015-03-18 13:35gitNote Added: 0038546
2015-03-18 13:35gitNote Added: 0038547
2015-05-14 15:29aivStatusverified => closed
2015-05-14 15:32aivFixed in Version => 6.9.0

Notes
(0036068)
gka   
2015-01-14 18:31   
In this case reason of exception is invalid curve written in file and your fix allows to avoid exception only for one particular case.

In all places except for StepToTopoDS_TranslateEdgeLoop where method StepToGeom_MakeCurve::Convert is called OCC_CATCH_SIGNALS to catch of exception is used. Seems that it will be better to add catching of exceptions in the StepToTopoDS_TranslateEdgeLoop method.
(0036141)
ventu   
2015-01-16 13:23   
Hello.
Thanks for your answer.
Forgive me, but I'm not so proficient about OpenCASCADE internals and I don't quite understand your answer.

I know my solution is but a dirty hack and I'm willing to help to find a better alternative, but I'm not able to code it, at least not without a suggestion.

Could you show me where to look for an example of a proper use of StepToGeom_MakeCurve::Convert?
(0036149)
gka   
2015-01-16 15:37   
Yuo can see in class StepToTopoDS_TranslateCompositeCurve.cxx
(0036178)
ventu   
2015-01-17 19:40   
Would the patch I attached be ok?
Thanks.
(0036691)
gka   
2015-01-27 11:26   
Attached patch is OK.
Thanks.
(0036812)
git   
2015-01-29 13:38   
Branch CR25699 has been created by akz.

SHA-1: 56aa434f7eb40e460f4d3a4ee2558184377da2ef


Detailed log of new commits:

Author: akz
Date: Thu Jan 29 13:25:51 2015 +0300

    0025699: Crash while importing STeP file
    
    Try-catch block was added on a StepToTopoDS_TranslateEdgeLoop::Init() to
    catch Standard_ConstructionError during the Curve conversion.
(0036816)
akz   
2015-01-29 14:02   
I've add the try-catch block on a StepToGeom_MakeCurve::Convert function, but STEPControl_ActorRead::TransferEntity already has a try-catch block which cover this exception too. So i can't find a way to read Step file bypassing a STEPControl_ActorRead to reproduce crash
(0036819)
abv   
2015-01-29 14:12   
The point is that access violation (access null pointer) will raise exception only if you have OCCT signal handler armed (by call to OSD_SetSignal()). It is not always done in actual applications, and sometimes it is just impossible (e.g. in .Net environment).
(0036837)
git   
2015-01-29 15:53   
Branch CR25699 has been updated forcibly by akz.

SHA-1: a7e26f2586ba46eeac032bc742c596cc42a594b2
(0036838)
akz   
2015-01-29 15:55   
Branch CR25699 is ready to be reviewed.
(0036874)
gka   
2015-01-30 10:27   
Besides it is desirable to add checks to avoid exception in the method StepToGeom_MakeCurve::Convert().
(0037257)
git   
2015-02-09 19:16   
Branch CR25699_1 has been created by akz.

SHA-1: e1605d176063f564dd8be7bd30eed55457050d3d


Detailed log of new commits:

Author: akz
Date: Thu Jan 29 13:25:51 2015 +0300

    0025699: Crash while importing STeP file
    
    1) Try-catch block was added on a StepToTopoDS_TranslateEdgeLoop::Init() to
    catch Standard_ConstructionError during the Curve conversion.
    
    2) Checks of BSpline curve degree added to prevent construction error when converting edges to BSpline_Curve.
    3) Warning message was added in case of incorrect curve definition.
(0037258)
git   
2015-02-09 19:17   
Branch CR25699 has been deleted by akz.

SHA-1: a7e26f2586ba46eeac032bc742c596cc42a594b2
(0037259)
akz   
2015-02-09 19:17   
Branch CR25699_1 is ready to be reviewed.
(0037274)
gka   
2015-02-10 12:04   
Branch CR25699_1 is ready to be tested
(0037446)
apv   
2015-02-12 15:41   
Dear BugMaster,

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

Number of compiler warnings:
occt component:
   Linux: 18 (18 on master)
   Windows: 0 (0 on master)
products component:
   Linux: 11 (11 on master)
   Windows: 0 (1 on master)

Regressions/Differences:
http://occt-tests/CR25699-1-master-occt/Debian60-64/summary.html [^]
http://occt-tests/CR25699-1-master-occt/Windows-32-VC10/summary.html [^]
de step_1(004) R9
de step_2(005) G5

Testing cases:
Not needed

Testing on Linux:
Total MEMORY difference: 85960213 / 86213434
Total CPU difference: 49363.479999999865 / 47866.67999999985

Testing on Windows:
Total MEMORY difference: 40639696 / 40648590
Total CPU difference: 36894.0625 / 32747.6875
(0037453)
git   
2015-02-12 16:36   
Branch CR25699_1 has been updated forcibly by akz.

SHA-1: 71871c5913f4c94e0fc968e6eac227f45c0d900f
(0037454)
git   
2015-02-12 16:41   
Branch CR25699_1 has been updated by akz.

SHA-1: fd2e5d4cf66f37468ccf0290da42414fb082d40e


Detailed log of new commits:

Author: akz
Date: Thu Feb 12 16:41:20 2015 +0300

    Correct of the test cases according to the new error message added with fix

(0037457)
git   
2015-02-12 16:46   
Branch CR25699_2 has been created by akz.

SHA-1: 98f36045a3087dbef255a2b3bfd461b31076152f


Detailed log of new commits:

Author: akz
Date: Thu Feb 12 16:41:20 2015 +0300

    Correct of the test cases according to the new error message added with fix
(0037458)
git   
2015-02-12 16:46   
Branch CR25699_1 has been deleted by akz.

SHA-1: fd2e5d4cf66f37468ccf0290da42414fb082d40e
(0037459)
akz   
2015-02-12 16:51   
Branch CR25699_2 is ready to review

Dear BugMaster, the new error message was added with this fix. The tests with differences contain STEP files which produce new error in TPSTAT.
Last commit contains the changes with number of errors including the new error.

(0037461)
gka   
2015-02-12 16:57   
Branch CR25699 can be integrated
(0037503)
git   
2015-02-13 13:09   
Branch CR25699_2 has been updated forcibly by apn.

SHA-1: c7f9d7025b5fddfb0ab8963717a88b0a5d1d4c12
(0037504)
git   
2015-02-13 13:11   
Branch CR25699_2 has been updated by apn.

SHA-1: e3c43ca7b137f320785663e8ca7a93ffb8ef1617


Detailed log of new commits:

Author: apn
Date: Fri Feb 13 13:11:11 2015 +0300

    Modified test cases according to new reference data

(0037515)
git   
2015-02-13 15:55   
Branch CR25699_2 has been updated forcibly by apn.

SHA-1: 8d1d3afb1c96327997d4d5790427fad4419afc39
(0037533)
git   
2015-02-13 18:25   
Branch CR25699_3 has been created by apn.

SHA-1: 8d1d3afb1c96327997d4d5790427fad4419afc39


No new revisions were added by this update.
(0037534)
git   
2015-02-13 18:26   
Branch CR25699_4 has been created by apn.

SHA-1: 8d1d3afb1c96327997d4d5790427fad4419afc39


No new revisions were added by this update.
(0037535)
git   
2015-02-13 18:27   
Branch CR25699_5 has been created by apn.

SHA-1: 8d1d3afb1c96327997d4d5790427fad4419afc39


No new revisions were added by this update.
(0037536)
git   
2015-02-13 18:28   
Branch CR25699_6 has been created by apn.

SHA-1: 8d1d3afb1c96327997d4d5790427fad4419afc39


No new revisions were added by this update.
(0038543)
git   
2015-03-18 13:35   
Branch CR25699_2 has been deleted by inv.

SHA-1: 8d1d3afb1c96327997d4d5790427fad4419afc39
(0038544)
git   
2015-03-18 13:35   
Branch CR25699_3 has been deleted by inv.

SHA-1: 8d1d3afb1c96327997d4d5790427fad4419afc39
(0038545)
git   
2015-03-18 13:35   
Branch CR25699_4 has been deleted by inv.

SHA-1: 8d1d3afb1c96327997d4d5790427fad4419afc39
(0038546)
git   
2015-03-18 13:35   
Branch CR25699_5 has been deleted by inv.

SHA-1: 8d1d3afb1c96327997d4d5790427fad4419afc39
(0038547)
git   
2015-03-18 13:35   
Branch CR25699_6 has been deleted by inv.

SHA-1: 8d1d3afb1c96327997d4d5790427fad4419afc39