View Issue Details

IDProjectCategoryView StatusLast Update
0033377CommunityOCCT:Data Exchangepublic2023-12-18 18:33
ReporterFrancoisLauzon Assigned Todpasukhi  
PrioritynormalSeveritycrash 
Status verifiedResolutionfixed 
PlatformWindowsOSVC++ 2019 
Product Version7.6.3 
Target Version7.7.2 
Summary0033377: Data Exchange - STEPCAFControl_Reader crash in OCC 7.7.0
DescriptionWhen importing a particular STEP file, the method STEPCAFControl_Reader::ExpandShell() crash when encountering and using a null StepShape_Vertex.
I tested the same step file with CAD Assistant 1.6 (which use OCC 7.6) and it doesn't crash.

I cannot supplied the step file in question, but I manage to fix STEPCAFControl_Reader and then successfully import the file.
Steps To ReproduceNot possible
Additional information
and documentation updates
Here are the 2 methods that I changed to fix the crash (simply add a test for null pointer):
void STEPCAFControl_Reader::ExpandShell(const Handle(StepShape_ConnectedFaceSet)& Shell,
  TDF_Label& RootLab,
  const Handle(Transfer_TransientProcess)& TP,
  const Handle(XCAFDoc_ShapeTool)& ShapeTool) const
{
  // Record CAF data
  SettleShapeData(Shell, RootLab, ShapeTool, TP);

  // Access faces
  Handle(StepShape_HArray1OfFace) aFaces = Shell->CfsFaces();
  for (Standard_Integer f = aFaces->Lower(); f <= aFaces->Upper(); ++f)
  {
    const Handle(StepShape_Face)& aFace = aFaces->Value(f);
    if (aFace.IsNull())
      continue;

    // Record CAF data
    SettleShapeData(aFace, RootLab, ShapeTool, TP);

    // Access face bounds
    Handle(StepShape_HArray1OfFaceBound) aWires = aFace->Bounds();
    if (aWires.IsNull())
      continue;
    for (Standard_Integer w = aWires->Lower(); w <= aWires->Upper(); ++w)
    {
      const Handle(StepShape_Loop)& aWire = aWires->Value(w)->Bound();

      // Record CAF data
      SettleShapeData(aWire, RootLab, ShapeTool, TP);

      // Access wire edges
      // Currently only EDGE LOOPs are considered (!)
      if (!aWire->IsInstance(STANDARD_TYPE(StepShape_EdgeLoop)))
        continue;

      // Access edges
      Handle(StepShape_EdgeLoop) anEdgeLoop = Handle(StepShape_EdgeLoop)::DownCast(aWire);
      Handle(StepShape_HArray1OfOrientedEdge) anEdges = anEdgeLoop->EdgeList();
      for (Standard_Integer e = anEdges->Lower(); e <= anEdges->Upper(); ++e)
      {
        Handle(StepShape_OrientedEdge) anOrientedEdge = anEdges->Value(e);
        if (anOrientedEdge.IsNull())
          continue;
        Handle(StepShape_Edge) anEdge = anOrientedEdge->EdgeElement();
        if (anEdge.IsNull())
          continue;

        // Record CAF data
        SettleShapeData(anEdge, RootLab, ShapeTool, TP);

        // Access vertices
        Handle(StepShape_Vertex) aV1 = anEdge->EdgeStart();
        Handle(StepShape_Vertex) aV2 = anEdge->EdgeEnd();

        // Record CAF data
        if (aV1.IsNull()==false)
            SettleShapeData(aV1, RootLab, ShapeTool, TP);
        if (aV2.IsNull()==false)
            SettleShapeData(aV2, RootLab, ShapeTool, TP);
      }
    }
  }
}

//=======================================================================
//function : SettleShapeData
//purpose  :
//=======================================================================

TDF_Label STEPCAFControl_Reader_priv::SettleShapeData(const Handle(StepRepr_RepresentationItem)& theItem,
  const TDF_Label& theLab,
  const Handle(XCAFDoc_ShapeTool)& theShapeTool,
  const Handle(Transfer_TransientProcess)& TP) const
{
  TDF_Label aResult = theLab;
  if (theItem.IsNull())
    return aResult;

  Handle(TCollection_HAsciiString) hName = theItem->Name();
  if (hName.IsNull() || hName->IsEmpty())
    return aResult;

  Handle(Transfer_Binder) aBinder = TP->Find(theItem);
  if (aBinder.IsNull())
    return aResult;

  TopoDS_Shape aShape = TransferBRep::ShapeResult(aBinder);
  if (aShape.IsNull())
    return aResult;

  // Allocate sub-Label
  aResult = theShapeTool->AddSubShape(theLab, aShape);
  if (aResult.IsNull())
    return aResult;

  TCollection_AsciiString aName = hName->String();
  TDataStd_Name::Set(aResult, aName);
  theShapeTool->SetShape(aResult, aShape);

  return aResult;
}
TagsNo tags attached.
Test case number

Activities

git

2023-05-10 21:29

administrator   ~0113453

Branch CR33377 has been created by dpasukhi.

SHA-1: e4f00dbb7e72cc187215666ad949c54526ece6f0


Detailed log of new commits:

Author: dpasukhi
Date: Wed May 10 19:26:55 2023 +0100

    0033377: Data Exchange - STEPCAFControl_Reader crash in OCC 7.7.0
    
    Added checking for null object for STEPCAFControl_Reader::SettleShapeData

dpasukhi

2023-05-10 21:31

administrator   ~0113454

Dear ika,
please review CR33377

There is just new checking for null object.
I think that this happened on not valid file, but as a fact we need to avoid crash.

Tests are not needed.

ika

2023-05-11 15:44

developer   ~0113459

No remarks.

Dear bugmaster,
please integrate
OCCT - CR33377

vglukhik

2023-05-15 16:34

administrator   ~0113485

Combination -
OCCT branch : IR-2023-05-12
Products branch : IR-2023-05-12
was compiled on Linux, MacOS and Windows platforms and tested in optimize mode.

Number of compiler warnings:
No new/fixed warnings

Regressions/Differences/Improvements:
No regressions/differences

CPU differences:
Ubuntu2004-64:
OCCT
Total CPU difference: 18189.300000000207 / 18355.18000000007 [-0.90%]
Products
Total CPU difference: 12137.909999999983 / 12171.56000000001 [-0.28%]
Windows-64-VC142:
OCCT
Total CPU difference: 19812.3125 / 20719.140625 [-4.38%]
Products
Total CPU difference: 5352.15625 / 5404.359375 [-0.97%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention

git

2023-12-18 18:33

administrator   ~0114811

Branch CR33377 has been deleted by vglukhik.

SHA-1: e4f00dbb7e72cc187215666ad949c54526ece6f0

Related Changesets

occt: master e4f00dbb

2023-05-10 18:26:55

dpasukhi

Details Diff
0033377: Data Exchange - STEPCAFControl_Reader crash in OCC 7.7.0

Added checking for null object for STEPCAFControl_Reader::SettleShapeData
Affected Issues
0033377
mod - src/STEPCAFControl/STEPCAFControl_Reader.cxx Diff File

Issue History

Date Modified Username Field Change
2023-05-10 21:18 FrancoisLauzon New Issue
2023-05-10 21:18 FrancoisLauzon Assigned To => ika
2023-05-10 21:22 dpasukhi Target Version => 7.7.2
2023-05-10 21:22 dpasukhi Summary STEPCAFControl_Reader crash in OCC 7.7.0 => Data Exchange - STEPCAFControl_Reader crash in OCC 7.7.0
2023-05-10 21:22 dpasukhi Additional Information Updated
2023-05-10 21:29 git Note Added: 0113453
2023-05-10 21:31 dpasukhi Status new => resolved
2023-05-10 21:31 dpasukhi Steps to Reproduce Updated
2023-05-10 21:31 dpasukhi Note Added: 0113454
2023-05-11 15:44 ika Assigned To ika => bugmaster
2023-05-11 15:44 ika Status resolved => reviewed
2023-05-11 15:44 ika Note Added: 0113459
2023-05-15 16:34 vglukhik Note Added: 0113485
2023-05-15 16:38 dpasukhi Changeset attached => occt master e4f00dbb
2023-05-15 16:38 dpasukhi Assigned To bugmaster => dpasukhi
2023-05-15 16:38 dpasukhi Status reviewed => verified
2023-05-15 16:38 dpasukhi Resolution open => fixed
2023-12-18 18:33 git Note Added: 0114811