MantisBT - Community
View Issue Details
0029979Community[OCCT] OCCT:Data Exchangepublic2018-07-23 18:112019-09-07 16:27
borm 
bugmaster 
normalcrash 
verifiedfixed 
WindowsVC++ 201510
[OCCT] 7.2.0 
[OCCT] 7.4.0 
bugs/step/bug29979
0029979: Data Exchange - Crash by reading STEP file
Hi, the OCCT crashes by reading the STEP file:

The crash callstack is:
>	TKSTEPBase.dll!StepShape_EdgeCurve::EdgeGeometry() Line 47	C++
     TKSTEP.dll!StepToTopoDS_TranslateEdgeLoop::Init(const opencascade::handle<StepShape_FaceBound> 
& FaceBound, const TopoDS_Face & Face, const opencascade::handle<Geom_Surface> & GeomSurf, 
const opencascade::handle<StepGeom_Surface> & StepSurf, const bool sameSense, StepToTopoDS_Tool 
& aTool, StepToTopoDS_NMTool & NMTool) Line 296	C++
     TKSTEP.dll!StepToTopoDS_TranslateFace::Init(const opencascade::handle<StepShape_FaceSurface> 
& FS, StepToTopoDS_Tool & aTool, StepToTopoDS_NMTool & NMTool) Line 330	C++
     TKSTEP.dll!StepToTopoDS_TranslateShell::Init(const opencascade::handle<StepShape_ConnectedFaceSet> 
& CFS, StepToTopoDS_Tool & aTool, StepToTopoDS_NMTool & NMTool) Line 93	C++
     TKSTEP.dll!StepToTopoDS_Builder::Init(const opencascade::handle<StepShape_ManifoldSolidBrep> 
& aManifoldSolid, const opencascade::handle<Transfer_TransientProcess> & TP) Line 210	C++
     
TKSTEP.dll!STEPControl_ActorRead::TransferEntity(const opencascade::handle<StepGeom_GeometricRepresentationItem> 
& start, const opencascade::handle<Transfer_TransientProcess> & TP, const bool isManifold) 
Line 1229	C++
     TKSTEP.dll!STEPControl_ActorRead::TransferShape(const opencascade::handle<Standard_Transient> 
& start, const opencascade::handle<Transfer_TransientProcess> & TP, const bool isManifold) 
Line 1499	C++
     TKSTEP.dll!STEPControl_ActorRead::TransferEntity(const opencascade::handle<StepShape_ShapeRepresentation> 
& sr, const opencascade::handle<Transfer_TransientProcess> & TP, bool & isBound) Line 
817	C++
     TKSTEP.dll!STEPControl_ActorRead::TransferEntity(const opencascade::handle<StepRepr_ShapeRepresentationRelationship> 
& und, const opencascade::handle<Transfer_TransientProcess> & TP, const int nbrep) Line 
1020	C++
     TKSTEP.dll!STEPControl_ActorRead::TransferEntity(const opencascade::handle<StepBasic_ProductDefinition> 
& PD, const opencascade::handle<Transfer_TransientProcess> & TP) Line 628	C++
     TKSTEP.dll!STEPControl_ActorRead::TransferEntity(const opencascade::handle<StepRepr_NextAssemblyUsageOccurrence> 
& NAUO, const opencascade::handle<Transfer_TransientProcess> & TP) Line 717	C++
     TKSTEP.dll!STEPControl_ActorRead::TransferEntity(const opencascade::handle<StepBasic_ProductDefinition> 
& PD, const opencascade::handle<Transfer_TransientProcess> & TP) Line 549	C++
     TKSTEP.dll!STEPControl_ActorRead::TransferShape(const opencascade::handle<Standard_Transient> 
& start, const opencascade::handle<Transfer_TransientProcess> & TP, const bool isManifold) 
Line 1460	C++
     TKSTEP.dll!STEPControl_ActorRead::Transfer(const opencascade::handle<Standard_Transient> & 
start, const opencascade::handle<Transfer_TransientProcess> & TP) Line 300	C++
     TKXSBase.dll!Transfer_ActorOfTransientProcess::Transferring(const opencascade::handle<Standard_Transient> 
& ent, const opencascade::handle<Transfer_ProcessForTransient> & TP) Line 40	C++
     TKXSBase.dll!Transfer_ProcessForTransient::TransferProduct(const opencascade::handle<Standard_Transient> 
& start) Line 1160	C++
     TKXSBase.dll!Transfer_ProcessForTransient::Transferring(const opencascade::handle<Standard_Transient> 
& start) Line 1067	C++
     TKXSBase.dll!Transfer_ProcessForTransient::Transfer(const opencascade::handle<Standard_Transient> 
& start) Line 1189	C++
     TKXSBase.dll!Transfer_TransferOutput::Transfer(const opencascade::handle<Standard_Transient> 
& obj) Line 79	C++
     TKXSBase.dll!XSControl_TransferReader::TransferOne(const opencascade::handle<Standard_Transient> 
& ent, const bool rec) Line 816	C++
     TKXSBase.dll!XSControl_Reader::TransferEntity(const opencascade::handle<Standard_Transient> 
& start) Line 242	C++
     TKXSBase.dll!XSControl_Reader::TransferOneRoot(const int num) Line 216	C++
     TKXDESTEP.dll!STEPCAFControl_Reader::Transfer(STEPControl_Reader & reader, const int nroot, 
opencascade::handle<TDocStd_Document> & doc, NCollection_Sequence<TDF_Label> & Lseq, 
const bool asOne) Line 522	C++
     TKXDESTEP.dll!STEPCAFControl_Reader::Transfer(opencascade::handle<TDocStd_Document> & 
doc) Line 404	C++
     TKXDESTEP.dll!STEPCAFControl_Reader::Perform(const char * const filename, opencascade::handle<TDocStd_Document> 
& doc) Line 418	C++
The following code produces a crash:

Handle(TDocStd_Document) pOcctDoc;
Handle(XCAFApp_Application) pOcctApp = XCAFApp_Application::GetApplication();
pOcctApp->NewDocument("MDTV-XCAF", pOcctDoc);

STEPCAFControl_Reader stepReader;
stepReader.SetColorMode(Standard_True);
stepReader.SetNameMode(Standard_True);
const auto result = stepReader.Perform(fileName, pOcctDoc);
No tags attached.
related to 0030541reviewed kgv Open CASCADE Draw Harness - impossible disabling signals 
7z Firetherm_12.7z (9,659,229) 2019-03-06 11:55
https://tracker.dev.opencascade.org/
Issue History
2018-07-23 18:11bormNew Issue
2018-07-23 18:11bormAssigned To => gka
2019-03-03 00:04kgvNote Added: 0082542
2019-03-03 00:04kgvAssigned Togka => borm
2019-03-03 00:04kgvStatusnew => feedback
2019-03-05 18:59bormNote Added: 0082701
2019-03-05 23:05kgvNote Added: 0082706
2019-03-05 23:06kgvNote Edited: 0082706bug_revision_view_page.php?bugnote_id=82706#r20791
2019-03-06 10:25kgvResolutionopen => unable to reproduce
2019-03-06 11:36bormNote Added: 0082723
2019-03-06 11:45kgvNote Added: 0082724
2019-03-06 11:45kgvAssigned Toborm => gka
2019-03-06 11:45kgvStatusfeedback => assigned
2019-03-06 11:45kgvResolutionunable to reproduce => open
2019-03-06 11:45kgvTarget Version => 7.5.0*
2019-03-06 11:52kgvRelationship addedrelated to 0030541
2019-03-06 11:53kgvSummaryCrash by reading STEP file => Data Exchange - Crash by reading STEP file
2019-03-06 11:55kgvFile Added: Firetherm_12.7z
2019-03-06 11:56kgvDescription Updatedbug_revision_view_page.php?rev_id=20797#r20797
2019-03-06 11:56kgvSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=20799#r20799
2019-03-06 11:56bormNote Added: 0082725
2019-03-06 12:05kgvRelationship addedrelated to 0030533
2019-03-20 08:31kgvNote Added: 0083122
2019-03-20 08:31kgvSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=20877#r20877
2019-07-09 14:44abvNote Added: 0085507
2019-07-09 14:44abvTarget Version7.5.0* => 7.4.0
2019-07-09 14:54gitNote Added: 0085509
2019-07-09 15:10abvNote Edited: 0085507bug_revision_view_page.php?bugnote_id=85507#r21479
2019-07-09 16:41gitNote Added: 0085518
2019-07-09 16:50abvNote Added: 0085519
2019-07-09 16:50abvStatusassigned => resolved
2019-07-09 16:50abvSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=21480#r21480
2019-09-06 18:51gkaNote Added: 0086913
2019-09-06 18:51gkaAssigned Togka => bugmaster
2019-09-06 18:51gkaStatusresolved => reviewed
2019-09-06 18:56bugmasterTest case number => bugs/step/bug29979
2019-09-07 11:38bugmasterChangeset attached => occt master fa68c1e1
2019-09-07 11:38bugmasterStatusreviewed => verified
2019-09-07 11:38bugmasterResolutionopen => fixed
2019-09-07 16:27gitNote Added: 0086952

Notes
(0082542)
kgv   
2019-03-03 00:04   
Referred file is inaccessible.
(0082701)
borm   
2019-03-05 18:59   
Hi, the link works again. Please download the file as the link expires on 31.3.2019 again. Thanks.
(0082706)
kgv   
2019-03-05 23:05   
(edited on: 2019-03-05 23:06)
I'm unable reproducing the crash with the following script:
pload ALL
ReadStep D "Firetherm 12.STEP"
XShow D
vfit



Are there any extra input requisites?
Or maybe wrong OCCT version is specified?

(0082723)
borm   
2019-03-06 11:36   
I'm not aware of the script code so I can comment just on the C++ code. The STEPCAFControl_Reader has to be used and the color and name mode must be set to true to reproduce the crash. I can still reproduce it with the OCCT 7.2.0 and I get the same crash callstack.
(0082724)
kgv   
2019-03-06 11:45   
OK, your application doesn't setup signals.

void StepToTopoDS_TranslateEdgeLoop::Init(
...
  for (j=1; j<=NbEdge; j++ ) {
    OrEdge1  = EL->EdgeListValue(j);
    StepEdge = OrEdge1->EdgeElement();
//    if(j>1 && StepEdge == StepEdge1) theSame++; //gka 15.12.98
    StepEdge1 = StepEdge;                         //
    Handle(StepShape_EdgeCurve) EC = Handle(StepShape_EdgeCurve)::DownCast(StepEdge);
    Handle(StepGeom_Curve) C = EC->EdgeGeometry();

EC becomes NULL here, because second edge in the loop is of type StepShape_OrientedEdge, not StepShape_EdgeCurve.
(0082725)
borm   
2019-03-06 11:56   
Can you please elaborate more on your comment? What does it mean that the application doesn't setup signal? What we need to do?

Still even if we don't setup the signals the code should not crash.
(0083122)
kgv   
2019-03-20 08:31   
Existing test case bugs/step/bug26451 can be used for reproducing the issue.
(0085507)
abv   
2019-07-09 14:44   
(edited on: 2019-07-09 15:10)
Attached STEP file has several problems:

1. List of faces in CLOSED_SHELL # 103322 include 8 entities which are not faces, for instance, # 487310 which is ORIENTED_EDGE. Wrong entities in the list are those with indices 116, 123, 192, 230, 243, 289, 345, 399.

2. 10 entities of type ORIENTED_EDGE (# 148, # 333389, ...) refer to another ORIENTED_EDGE instead of EDGE_CURVE, which violates requirement WR1 or ORIENTED_EDGE entity.

Problem 2 is the one that causes exception (current code assumes that ORIENTED_EDGE contains EDGE_CURVE). Work-around against this problem can be implemented.

(0085509)
git   
2019-07-09 14:54   
Branch CR29979 has been created by abv.

SHA-1: 585970baa7a2647c63932b726bc3d1c7aa61201e


Detailed log of new commits:

Author: abv
Date: Tue Jul 9 14:47:21 2019 +0300

    0029979: Data Exchange - Crash by reading STEP file
    
    Added work-around against specific problem of ORIENTED_EDGE referring to another ORIENTED_EDGE instead of EDGE_CURVE.
    Added handling of edges with null EDGE_CURVE, to allow passing the translation further instead of exception.
    
    Off-topic: text of warning message is corrected in genproj
(0085518)
git   
2019-07-09 16:41   
Branch CR29979 has been updated by abv.

SHA-1: ec318219d7b6b153e18e447154751ee89ddca914


Detailed log of new commits:

Author: abv
Date: Tue Jul 9 16:40:15 2019 +0300

    Added test bugs step bug29979

(0085519)
abv   
2019-07-09 16:50   
Fix is pushed to CR29979, please review. Tests passed with no differences, see Jenkins job CR29979-master-abv. Note that test bugs step bug26451 is not related to this problem (even if similar errors are reported).
(0086913)
gka   
2019-09-06 18:51   
Branch CR29979 was reviewed
(0086952)
git   
2019-09-07 16:27   
Branch CR29979 has been deleted by inv.

SHA-1: ec318219d7b6b153e18e447154751ee89ddca914