MantisBT - Community
View Issue Details
0030552Community[OCCT] OCCT:Foundation Classespublic2019-03-09 18:142019-03-12 13:55
galbramc 
kgv 
normalmajor 
newopen 
MacOSX
[OCCT] 6.7.0 
 
0030552: Foundation Classes - Stack overflow due to math_SingleTab static array size
I got the following stack overflow error when running OCCT on OSX copmiled with the -fsanitize=address clang compiler flag:

==76206==ERROR: AddressSanitizer: stack-overflow on address 0x70000fa94f00 (pc 0x0001106876dc bp 0x70000fa9c190 sp 0x70000fa94f00 T41)
    #0 0x1106876db in GeomInt_ParLeastSquareOfMyGradientOfTheComputeLineBezierOfWLApprox::MakeTAA(math_Vector&, math_Vector&) AppParCurves_LeastSquare.gxx:1377
    0000001 0x11067bf87 in GeomInt_ParLeastSquareOfMyGradientOfTheComputeLineBezierOfWLApprox::Perform(math_Vector const&) AppParCurves_LeastSquare.gxx:644
    0000002 0x11063c631 in GeomInt_ParFunctionOfMyGradientOfTheComputeLineBezierOfWLApprox::Perform(math_Vector const&) AppParCurves_Function.gxx:268
    #3 0x11064e782 in GeomInt_ParFunctionOfMyGradientOfTheComputeLineBezierOfWLApprox::Values(math_Vector const&, double&, math_Vector&) AppParCurves_Function.gxx:589
    #4 0x1112c8660 in math_BFGS::Perform(math_MultipleVarFunctionWithGradient&, math_Vector const&) math_BFGS.cxx:338
    #5 0x1105c6285 in GeomInt_Gradient_BFGSOfMyGradientOfTheComputeLineBezierOfWLApprox::GeomInt_Gradient_BFGSOfMyGradientOfTheComputeLineBezierOfWLApprox(math_MultipleVarFunctionWithGradient&, math_Vector const&, double, double, double, int) AppParCurves_Gradient_BFGS.gxx:31
    #6 0x11061b256 in GeomInt_MyGradientOfTheComputeLineBezierOfWLApprox::GeomInt_MyGradientOfTheComputeLineBezierOfWLApprox(GeomInt_TheMultiLineOfWLApprox const&, int, int, opencascade::handle<AppParCurves_HArray1OfConstraintCouple> const&, math_Vector&, int, double, double, int) AppParCurves_Gradient.gxx:186
    0000007 0x1106c0b28 in GeomInt_TheComputeLineBezierOfWLApprox::Compute(GeomInt_TheMultiLineOfWLApprox const&, int, int, math_Vector&, double&, double&, int&) Approx_ComputeLine.gxx:1281
    0000008 0x1106b9891 in GeomInt_TheComputeLineBezierOfWLApprox::Perform(GeomInt_TheMultiLineOfWLApprox const&) Approx_ComputeLine.gxx:1114
    0000009 0x110709a56 in GeomInt_WLApprox::buildCurve(opencascade::handle<IntPatch_WLine> const&, void*) ApproxInt_Approx.gxx:646
    #10 0x11070bdf8 in GeomInt_WLApprox::Perform(IntSurf_Quadric const&, opencascade::handle<Adaptor3d_HSurface> const&, opencascade::handle<IntPatch_WLine> const&, bool, bool, bool, int, int, bool) ApproxInt_Approx.gxx:386
    0000011 0x11070b170 in GeomInt_WLApprox::Perform(opencascade::handle<Adaptor3d_HSurface> const&, opencascade::handle<Adaptor3d_HSurface> const&, opencascade::handle<IntPatch_WLine> const&, bool, bool, bool, int, int) ApproxInt_Approx.gxx:297
    #12 0x110061735 in IntTools_FaceFace::MakeCurve(int, opencascade::handle<Adaptor3d_TopolTool> const&, opencascade::handle<Adaptor3d_TopolTool> const&, double) IntTools_FaceFace.cxx:1257
    0000013 0x11005747b in IntTools_FaceFace::Perform(TopoDS_Face const&, TopoDS_Face const&) IntTools_FaceFace.cxx:564
    0000014 0x11027afd1 in BOPAlgo_FaceFace::Perform() BOPAlgo_PaveFiller_6.cxx:151
    0000015 0x10f879a0e in (anonymous namespace)::OSD_Parallel_Threads::Task::Run(void*) OSD_Parallel_Threads.cxx:106
    0000016 0x7fff5527f660 in _pthread_body (libsystem_pthread.dylib:x86_64+0x3660)
    0000017 0x7fff5527f50c in _pthread_start (libsystem_pthread.dylib:x86_64+0x350c)
    0000018 0x7fff5527ebf8 in thread_start (libsystem_pthread.dylib:x86_64+0x2bf8)

SUMMARY: AddressSanitizer: stack-overflow AppParCurves_LeastSquare.gxx:1377 in GeomInt_ParLeastSquareOfMyGradientOfTheComputeLineBezierOfWLApprox::MakeTAA(math_Vector&, math_Vector&)
Thread T41 created by T0 here:
    #0 0x10de9de1d in wrap_pthread_create (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x4ee1d)
    0000001 0x10f886308 in OSD_Thread::Run(void*, int) OSD_Thread.cxx:159
    0000002 0x10f879062 in OSD_Parallel::forEach(OSD_Parallel::UniversalIterator&, OSD_Parallel::UniversalIterator&, OSD_Parallel::FunctorInterface const&) OSD_Parallel_Threads.cxx:144
    #3 0x11027be82 in void OSD_Parallel::For<BOPTools_Functor<BOPAlgo_FaceFace, NCollection_Vector<BOPAlgo_FaceFace> > >(int, int, BOPTools_Functor<BOPAlgo_FaceFace, NCollection_Vector<BOPAlgo_FaceFace> > const&, bool) OSD_Parallel.hxx:324
    #4 0x11023aab6 in BOPAlgo_PaveFiller::PerformFF() BOPTools_Parallel.hxx:70
    #5 0x1101f4041 in BOPAlgo_PaveFiller::PerformInternal() BOPAlgo_PaveFiller.cxx:294
    #6 0x1101f369a in BOPAlgo_PaveFiller::Perform() BOPAlgo_PaveFiller.cxx:235
    0000007 0x1100c1ed5 in BRepAlgoAPI_BooleanOperation::Build() BRepAlgoAPI_BooleanOperation.cxx:318
    0000008 0x1100d55cc in BRepAlgoAPI_Fuse::BRepAlgoAPI_Fuse(TopoDS_Shape const&, TopoDS_Shape const&) BRepAlgoAPI_Fuse.cxx:61
    0000009 0x10d9556ad in EG_solidBoolean egadsHLevel.cpp:1505
    #10 0x10d78d733 in solidBoolean OpenCSM.c:35948
    0000011 0x10d5fe96a in buildBoolean OpenCSM.c:18358
    #12 0x10d50ec78 in ocsmBuild OpenCSM.c:6048
    0000013 0x10d3d3015 in buildBodys serveCSM.c:1833
    0000014 0x10d3c9f34 in main serveCSM.c:740
    0000015 0x7fff54f67014 in start (libdyld.dylib:x86_64+0x1014)

I was able to track this back to the static size of

static const Standard_Integer aLengthOfBuf = 512;

in src/math/math_SingleTab.hxx. Reducing the size of this buffer resolves the issue.
Compile OCCT on OSX with -fsanitize=address and run the test suite. I can provide a more specific example if needed.
No tags attached.
related to 0030558verified apn Open CASCADE Coding - replace math_SingleTab with NCollection_LocalArray 
child of 0030557new kgv Open CASCADE Coding - eliminate errors reported by -fsanitize 
child of 0024044closed bugmaster Community Performance improvements: Foundation Classes (math) 
Issue History
2019-03-09 18:14galbramcNew Issue
2019-03-09 18:14galbramcAssigned To => abv
2019-03-12 04:40galbramcAssigned Toabv => kgv
2019-03-12 05:00kgvRelationship addedchild of 0030557
2019-03-12 06:06kgvSummaryStack overflow due to math_SingleTab static array size => Foundation Classes - Stack overflow due to math_SingleTab static array size
2019-03-12 06:50kgvRelationship addedrelated to 0030558
2019-03-12 06:55kgvProduct Version7.3.0 => 6.7.1
2019-03-12 06:55kgvRelationship addedchild of 0024044
2019-03-12 06:57kgvProduct Version6.7.1 => 6.7.0
2019-03-12 10:57gitNote Added: 0082866
2019-03-12 11:19gitNote Added: 0082867
2019-03-12 13:18gitNote Added: 0082869
2019-03-12 13:50gitNote Added: 0082870
2019-03-12 13:55gitNote Added: 0082871

Notes
(0082866)
git   
2019-03-12 10:57   
Branch CR30552 has been created by kgv.

SHA-1: 0652ae3717b0088549a80827ece9747533e4dde2


Detailed log of new commits:

Author: kgv
Date: Tue Mar 12 10:51:40 2019 +0300

    0030552: Foundation Classes - Stack overflow due to math_SingleTab static array size
    
    math_Vector, math_IntegerVector - static size of NCollection_LocalArray has been reduced from 512 to 32.

Author: kgv
Date: Tue Mar 12 06:05:21 2019 +0300

    0030558: Coding - replace math_SingleTab with NCollection_LocalArray
    
    math_Vector::Multiplied() - fixed modification of original array.
    
    math_SVD::Solve(), math_SVD::PseudoInverse(), GeomFill_LocationGuide::InitX() - removed incorrect constness.
    
    math_Vector, math_IntegerVector - math_SingleTab has been replaced by NCollection_LocalArray+NCollection_Array1.
    Added accessors returning const value.
(0082867)
git   
2019-03-12 11:19   
Branch CR30552_1 has been created by kgv.

SHA-1: 70453cd8c82e7458b1591e34dfd621358dd9767b


Detailed log of new commits:

Author: kgv
Date: Tue Mar 12 11:14:15 2019 +0300

    math_Vector, math_IntegerVector - added move constructors.
(0082869)
git   
2019-03-12 13:18   
Branch CR30552_1 has been updated forcibly by kgv.

SHA-1: c54d2e676e8c457afdf80ae2a24825597050d9ed
(0082870)
git   
2019-03-12 13:50   
Branch CR30552_1 has been updated forcibly by kgv.

SHA-1: 30e4f081678d5ec84ff986dd4cf8cb134318cf7e
(0082871)
git   
2019-03-12 13:55   
Branch CR30552_1 has been updated forcibly by kgv.

SHA-1: fca968d2fa64aff5650c2cadf8ebb11c74089567