Flaw of void BSplCLib::LocateParameter

In BSplCLib::LocateParameter (called by SameParameter API), it will produce crash bug in some extreme case (OCC6.5.3 and OCC6.7.1). If your program got crash after stitching(sewing) in release version, it may be produced by BSplCLib::LocateParameter. Here is the code:
void BSplCLib::LocateParameter
(const TColStd_Array1OfReal& Knots,
const Standard_Real U,
const Standard_Boolean IsPeriodic,
const Standard_Integer FromK1,
const Standard_Integer ToK2,
Standard_Integer& KnotIndex,
Standard_Real& NewU,
const Standard_Real UFirst,
const Standard_Real ULast)
Standard_Integer maxSize = Knots.Upper()-Knots.Lower();
while (val KnotIndex++;
K1 = K2;
//my code here
throw Standard_Failure("BSplCLib::LocateParameter");
K2 = knots[KnotIndex + 1];
val = K2 - K1;
if (val }


Rajeev Jain's picture

Hi Ding,
What is the fix?
I have a similar error:

Geometry engine set to: OpenCascade 6.8

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
0x00000001034d63ce in BSplCLib::LocateParameter ()
(gdb) bt
#0 0x00000001034d63ce in BSplCLib::LocateParameter ()
#1 0x00000001034efe7e in PrepareEval ()
#2 0x00000001034efda9 in BSplCLib::D0 ()
#3 0x00000001033311af in Geom_BSplineCurve::LocalD0 ()
#4 0x00000001033310bf in Geom_BSplineCurve::LocalValue ()
#5 0x0000000103379774 in GeomAdaptor_Curve::Value ()
#6 0x00000001026808c5 in Project ()
#7 0x000000010267e133 in BRepLib_MakeEdge::BRepLib_MakeEdge ()
#8 0x00000001026bd270 in BRepBuilderAPI_MakeEdge::BRepBuilderAPI_MakeEdge ()
#9 0x00000001000161a1 in OCCModifyEngine::make_Curve ()