DiscussionsIssue archiveOCCT:Modeling Algorithms

Archived issue #0026778

BRepFilletAPI_MakeFillet crash

CommunityOCCT:Modeling Algorithmsclosed36 public notes

Search issues

Description

Strange crash when trying to apply fillet on the attached shape. Only occurs in release mode (-ofast, -o3, -o2)

Reproduced on Mac OS X and iOS.

Steps to reproduce

std::ifstream file("Attachment 1 (BREP)");
TopoDS_Shape shape;
    BRep_Builder b;
    BRepTools::Read(shape, file, b);
    for (TopExp_Explorer exp(shape, TopAbs_EDGE); exp.More(); exp.Next())
    {
        try
        {
            BRepFilletAPI_MakeFillet filletMaker(shape);
            filletMaker.Add(0.165405, TopoDS::Edge(exp.Current()));
            filletMaker.Build();
        }
        catch (...)
        {
        }
    }

Additional information

Call stack:

#0 0x00000001056baaaa in AdvApp2Var_ApproxF2var::mma2fnc_(int*, int*, int*, double*, AdvApp2Var_EvaluatorFunc2Var const&, double*, int*, int*, double*, int*, int*, int*, int*, int*, double*, int*, double*, int*, double*, double*, double*, double*, double*, double*, double*, int*) at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ios:734
#0000001 0x00000001056c41b8 in AdvApp2Var_Iso::MakeApprox(AdvApp2Var_Context const&, double, double, double, double, AdvApp2Var_EvaluatorFunc2Var const&, AdvApp2Var_Node&, AdvApp2Var_Node&) at [user path removed]/occt_git/occt/src/AdvApp2Var/AdvApp2Var_Iso.cxx:284
#0000002 0x00000001056a919d in AdvApp2Var_ApproxAFunc2Var::ComputeConstraints(AdvApprox_Cutting const&, AdvApprox_Cutting const&, AdvApp2Var_EvaluatorFunc2Var const&) at [user path removed]/occt_git/occt/src/AdvApp2Var/AdvApp2Var_ApproxAFunc2Var.cxx:579
#3 0x00000001056a7ca8 in AdvApp2Var_ApproxAFunc2Var::ComputePatches(AdvApprox_Cutting const&, AdvApprox_Cutting const&, AdvApp2Var_EvaluatorFunc2Var const&) at [user path removed]/occt_git/occt/src/AdvApp2Var/AdvApp2Var_ApproxAFunc2Var.cxx:360
#4 0x00000001056a4f16 in AdvApp2Var_ApproxAFunc2Var::Perform(AdvApprox_Cutting const&, AdvApprox_Cutting const&, AdvApp2Var_EvaluatorFunc2Var const&) [inlined] at [user path removed]/occt_git/occt/src/AdvApp2Var/AdvApp2Var_ApproxAFunc2Var.cxx:322
#5 0x00000001056a4f0e in AdvApp2Var_ApproxAFunc2Var::AdvApp2Var_ApproxAFunc2Var(int, int, int, opencascade::handle<TColStd_HArray1OfReal> const&, opencascade::handle<TColStd_HArray1OfReal> const&, opencascade::handle<TColStd_HArray1OfReal> const&, opencascade::handle<TColStd_HArray2OfReal> const&, opencascade::handle<TColStd_HArray2OfReal> const&, opencascade::handle<TColStd_HArray2OfReal> const&, double, double, double, double, GeomAbs_IsoType, GeomAbs_Shape, GeomAbs_Shape, int, int, int, int, AdvApp2Var_EvaluatorFunc2Var const&, AdvApprox_Cutting&, AdvApprox_Cutting&) at [user path removed]/occt_git/occt/src/AdvApp2Var/AdvApp2Var_ApproxAFunc2Var.cxx:104
#6 0x00000001051cc053 in GeomPlate_MakeApprox::GeomPlate_MakeApprox(opencascade::handle<GeomPlate_Surface> const&, double, int, int, double, int, GeomAbs_Shape, double) at [user path removed]/occt_git/occt/src/GeomPlate/GeomPlate_MakeApprox.cxx:399
#0000007 0x00000001051b9ae0 in GeomPlate_BuildPlateSurface::ComputeSurfInit() at [user path removed]/occt_git/occt/src/GeomPlate/GeomPlate_BuildPlateSurface.cxx:1697
#0000008 0x00000001051b5eda in GeomPlate_BuildPlateSurface::Perform() at [user path removed]/occt_git/occt/src/GeomPlate/GeomPlate_BuildPlateSurface.cxx:484
#0000009 0x0000000104a5c88e in ChFi3d_Builder::PerformMoreThreeCorner(int, int) at [user path removed]/occt_git/occt/src/ChFi3d/ChFi3d_Builder_CnCrn.cxx:2630
#10 0x0000000104a17d29 in ChFi3d_Builder::PerformIntersectionAtEnd(int) at [user path removed]/occt_git/occt/src/ChFi3d/ChFi3d_Builder_C1.cxx:1693
#0000011 0x00000001049a6b28 in ChFi3d_Builder::PerformFilletOnVertex(int) at [user path removed]/occt_git/occt/src/ChFi3d/ChFi3d_Builder.cxx:725
#12 0x00000001049a436e in ChFi3d_Builder::Compute() at [user path removed]/occt_git/occt/src/ChFi3d/ChFi3d_Builder.cxx:298

Public activity

36 archived notes

Participants are labeled by their role within this record.

01Commenter 1
Could you tell what kind of exception occurs?
02Author
It crashes with
EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode = 0x0)
03Commenter 3
When I insert debugging printout like this:

   catch (Standard_Failure)
   {
      std::cout << i << " crash" << Standard_Failure::Caught() << endl;
   }

I obtain the following output (Windows, VS 2010, win32, release):

3 crash00891450 : Standard_Failure: There are no suitable edges for chamfer or fillet
4 crash00891450 : Standard_Failure: There are no suitable edges for chamfer or fillet
17 crash00891450 : Standard_Failure: There are no suitable edges for chamfer or fillet
18 crash00891450 : Standard_Failure: There are no suitable edges for chamfer or fillet
19 crash00891450 : Standard_Failure: There are no suitable edges for chamfer or fillet
20 crash00891450 : Standard_Failure: There are no suitable edges for chamfer or fillet
23 crash00891450 : Standard_Failure: There are no suitable edges for chamfer or fillet
38 crash00891450 : Standard_Failure: There are no suitable edges for chamfer or fillet
39 crash00891450 : Standard_Failure: There are no suitable edges for chamfer or fillet
42 crash00891450 : Standard_Failure: There are no suitable edges for chamfer or fillet
43 crash00891450 : Standard_Failure: There are no suitable edges for chamfer or fillet
44 crash00891450 : Standard_Failure: There are no suitable edges for chamfer or fillet
45 crash00891450 : Standard_Failure: There are no suitable edges for chamfer or fillet
51 crash00891450 : Standard_Failure: There are no suitable edges for chamfer or fillet
52 crash00891450 : Standard_Failure: There are no suitable edges for chamfer or fillet

It means the algorithm complains about incorrect input data.
04Commenter 4
Sorry, forgot to tell that 'i' is the simple cycle variable counting edges.
05Author
Yes, for a few edges it throws exceptions. It is OK. But for two edges it crashes. Can you try it on a Mac, with Clang? Probably this crash is related to Clang's optimization, that's why it does not crash with Visual C++.
06Author
Here is a sample disassembly from the crash (it crashes at the line marked with ->):

    0x104e1c921 <+8353>: movsd 0x8(%rdx,%rax,8), %xmm0
    0x104e1c927 <+8359>: movsd %xmm0, -0xa20(%rbp)
    0x104e1c92f <+8367>: movsd (%rdx,%rax,8), %xmm0
    0x104e1c934 <+8372>: movsd %xmm0, -0xa18(%rbp)
    0x104e1c93c <+8380>: movl %r12d, %ecx
    0x104e1c93f <+8383>: subl %eax, %ecx
    0x104e1c941 <+8385>: shll $0x3, %ecx
    0x104e1c944 <+8388>: movl %ecx, -0xc8(%rbp)
    0x104e1c94a <+8394>: leaq 0x10(%rdx,%rax,8), %rdx
    0x104e1c94f <+8399>: leaq -0xc8(%rbp), %rdi
    0x104e1c956 <+8406>: movq %r14, %rsi
    0x104e1c959 <+8409>: callq 0x104e430f0 ; AdvApp2Var_SysBase::mcrfill_ at AdvApp2Var_SysBase.cxx:2425
    0x104e1c95e <+8414>: movsd -0xa18(%rbp), %xmm0
    0x104e1c966 <+8422>: addsd -0xa20(%rbp), %xmm0
    0x104e1c96e <+8430>: mulsd 0x2e728a(%rip), %xmm0 ; typeinfo name for Geom_BoundedSurface + 64
    0x104e1c976 <+8438>: movsd %xmm0, (%r14)
    0x104e1c97b <+8443>: incl %r12d
    0x104e1c97e <+8446>: movl %r12d, -0xafc(%rbp)
    0x104e1c985 <+8453>: movl (%rbx), %eax
    0x104e1c987 <+8455>: cmpl %eax, %r12d
    0x104e1c98a <+8458>: movq %r15, %rbx
    0x104e1c98d <+8461>: jne 0x104e1aee0 ; <+1632> at AdvApp2Var_ApproxF2var.cxx:6478
    0x104e1c993 <+8467>: jmp 0x104e1c9a2 ; <+8482> at AdvApp2Var_ApproxF2var.cxx:6668
    0x104e1c995 <+8469>: movq 0xa8(%rbp), %rax
    0x104e1c99c <+8476>: movl $0x1, (%rax)
    0x104e1c9a2 <+8482>: cmpq $0x0, -0xd8(%rbp)
    0x104e1c9aa <+8490>: je 0x104e1c9d6 ; <+8534> at AdvApp2Var_ApproxF2var.cxx:6671
    0x104e1c9ac <+8492>: leaq -0xa10(%rbp), %rdi
    0x104e1c9b3 <+8499>: leaq -0xb8(%rbp), %rsi
    0x104e1c9ba <+8506>: leaq -0xcc(%rbp), %rdx
    0x104e1c9c1 <+8513>: leaq -0xd8(%rbp), %r8
    0x104e1c9c8 <+8520>: leaq -0xe0(%rbp), %r9
    0x104e1c9cf <+8527>: xorl %ecx, %ecx
    0x104e1c9d1 <+8529>: callq 0x104e41fd0 ; AdvApp2Var_SysBase::mcrdelt_ at AdvApp2Var_SysBase.cxx:2136
    0x104e1c9d6 <+8534>: cmpl $0x0, -0xe0(%rbp)
    0x104e1c9dd <+8541>: jle 0x104e1c9ee ; <+8558> at AdvApp2Var_ApproxF2var.cxx:6672
    0x104e1c9df <+8543>: movq 0xa8(%rbp), %rax
    0x104e1c9e6 <+8550>: movl $0xd, (%rax)
    0x104e1c9ec <+8556>: jmp 0x104e1c9fa ; <+8570> at AdvApp2Var_ApproxF2var.cxx:6681
    0x104e1c9ee <+8558>: movq 0xa8(%rbp), %rax
    0x104e1c9f5 <+8565>: cmpl $0x0, (%rax)
    0x104e1c9f8 <+8568>: je 0x104e1ca12 ; <+8594> at AdvApp2Var_ApproxF2var.cxx:6683
    0x104e1c9fa <+8570>: leaq 0x2e4b94(%rip), %rdi ; "MMA2FNC"
    0x104e1ca01 <+8577>: movl $0x7, %edx
    0x104e1ca06 <+8582>: movq 0xa8(%rbp), %rsi
    0x104e1ca0d <+8589>: callq 0x104e422d0 ; AdvApp2Var_SysBase::maermsg_ at AdvApp2Var_SysBase.cxx:1152
    0x104e1ca12 <+8594>: cmpl $0x2, -0xa84(%rbp)
    0x104e1ca19 <+8601>: jl 0x104e1ca2c ; <+8620> at AdvApp2Var_ApproxF2var.cxx:6684
    0x104e1ca1b <+8603>: leaq 0x2e4b73(%rip), %rdi ; "MMA2FNC"
    0x104e1ca22 <+8610>: movl $0x7, %esi
    0x104e1ca27 <+8615>: callq 0x104e43440 ; AdvApp2Var_SysBase::mgsomsg_ at AdvApp2Var_SysBase.cxx:3039
    0x104e1ca2c <+8620>: leaq -0xa10(%rbp), %rdi
    0x104e1ca33 <+8627>: callq 0x104e41c50 ; AdvApp2Var_SysBase::~AdvApp2Var_SysBase at AdvApp2Var_SysBase.cxx:145
    0x104e1ca38 <+8632>: movq 0x3ecf89(%rip), %rax ; (void *)0x000000010d9fb070: __stack_chk_guard
    0x104e1ca3f <+8639>: movq (%rax), %rax
    0x104e1ca42 <+8642>: cmpq -0x30(%rbp), %rax
    0x104e1ca46 <+8646>: jne 0x104e1ca85 ; <+8709> at AdvApp2Var_ApproxF2var.cxx:6687
    0x104e1ca48 <+8648>: xorl %eax, %eax
    0x104e1ca4a <+8650>: addq $0xc48, %rsp
    0x104e1ca51 <+8657>: popq %rbx
    0x104e1ca52 <+8658>: popq %r12
    0x104e1ca54 <+8660>: popq %r13
    0x104e1ca56 <+8662>: popq %r14
    0x104e1ca58 <+8664>: popq %r15
    0x104e1ca5a <+8666>: popq %rbp
    0x104e1ca5b <+8667>: retq
    0x104e1ca5c <+8668>: ud2
    0x104e1ca5e <+8670>: jmp 0x104e1ca6c ; <+8684> at AdvApp2Var_ApproxF2var.cxx:6687
    0x104e1ca60 <+8672>: jmp 0x104e1ca6c ; <+8684> at AdvApp2Var_ApproxF2var.cxx:6687
    0x104e1ca62 <+8674>: jmp 0x104e1ca6c ; <+8684> at AdvApp2Var_ApproxF2var.cxx:6687
    0x104e1ca64 <+8676>: jmp 0x104e1ca6c ; <+8684> at AdvApp2Var_ApproxF2var.cxx:6687
    0x104e1ca66 <+8678>: jmp 0x104e1ca6c ; <+8684> at AdvApp2Var_ApproxF2var.cxx:6687
    0x104e1ca68 <+8680>: jmp 0x104e1ca6c ; <+8684> at AdvApp2Var_ApproxF2var.cxx:6687
    0x104e1ca6a <+8682>: jmp 0x104e1ca6c ; <+8684> at AdvApp2Var_ApproxF2var.cxx:6687
    0x104e1ca6c <+8684>: movq %rax, %rbx
    0x104e1ca6f <+8687>: leaq -0xa10(%rbp), %rdi
    0x104e1ca76 <+8694>: callq 0x104e41c50 ; AdvApp2Var_SysBase::~AdvApp2Var_SysBase at AdvApp2Var_SysBase.cxx:145
    0x104e1ca7b <+8699>: movq %rbx, %rdi
    0x104e1ca7e <+8702>: callq 0x1050bcb0a ; symbol stub for: _Unwind_Resume
    0x104e1ca83 <+8707>: ud2
    0x104e1ca85 <+8709>: callq 0x1050bcb1c ; symbol stub for: __stack_chk_fail
    0x104e1ca8a <+8714>: jmp 0x104e1ca6c ; <+8684> at AdvApp2Var_ApproxF2var.cxx:6687
    0x104e1ca8c <+8716>: jmp 0x104e1ca6c ; <+8684> at AdvApp2Var_ApproxF2var.cxx:6687
    0x104e1ca8e <+8718>: movq %rax, %rbx
    0x104e1ca91 <+8721>: leaq -0x80(%rbp), %rdi
    0x104e1ca95 <+8725>: callq 0x1050bcaf8 ; symbol stub for: std::__1::locale::~locale()
    0x104e1ca9a <+8730>: jmp 0x104e1ca6f ; <+8687> at AdvApp2Var_ApproxF2var.cxx:6687
    0x104e1ca9c <+8732>: movq %rax, %rbx
    0x104e1ca9f <+8735>: leaq -0x78(%rbp), %rdi
    0x104e1caa3 <+8739>: callq 0x1050bcaf8 ; symbol stub for: std::__1::locale::~locale()
    0x104e1caa8 <+8744>: jmp 0x104e1ca6f ; <+8687> at AdvApp2Var_ApproxF2var.cxx:6687
-> 0x104e1caaa <+8746>: ud2
    0x104e1caac <+8748>: jmp 0x104e1ca6c ; <+8684> at AdvApp2Var_ApproxF2var.cxx:6687
    0x104e1caae <+8750>: jmp 0x104e1ca6c ; <+8684> at AdvApp2Var_ApproxF2var.cxx:6687
    0x104e1cab0 <+8752>: ud2
    0x104e1cab2 <+8754>: jmp 0x104e1ca6c ; <+8684> at AdvApp2Var_ApproxF2var.cxx:6687
07Author
Here is the same for iOS (ARM assembly):

    0x102450bb8 <+5920>: sxtw x8, w8
    0x102450bbc <+5924>: ldr x9, [sp, #184]
    0x102450bc0 <+5928>: sub x8, x8, x9
    0x102450bc4 <+5932>: lsl x19, x8, #3
    0x102450bc8 <+5936>: ldr x8, [sp, #328]
    0x102450bcc <+5940>: add x3, x8, x19
    0x102450bd0 <+5944>: str wzr, [sp, #2956]
    0x102450bd4 <+5948>: ldr x8, [sp, #536]
    0x102450bd8 <+5952>: ldr w8, [x8]
    0x102450bdc <+5956>: cmp w8, #0
    0x102450be0 <+5960>: cinc w8, w8, lt
    0x102450be4 <+5964>: asr w8, w8, #0000001
    0x102450be8 <+5968>: add w8, w8, #0000001
    0x102450bec <+5972>: ldr w9, [x24]
    0x102450bf0 <+5976>: mul w8, w8, w9
    0x102450bf4 <+5980>: stur w8, [x29, #-244]
    0x102450bf8 <+5984>: sub x0, x29, #184
    0x102450bfc <+5988>: sub x1, x29, #0000244
    0x102450c00 <+5992>: add x2, sp, #2956
    0x102450c04 <+5996>: sub x4, x29, #152
    0x102450c08 <+6000>: mov x5, x22
    0x102450c0c <+6004>: mov x6, x25
    0x102450c10 <+6008>: mov x7, x3
    0x102450c14 <+6012>: bl 0x102450e5c ; mma1noc_(double*, int*, int*, double*, double*, int*, int*, double*) at AdvApp2Var_ApproxF2var.cxx:1440
    0x102450c18 <+6016>: ldr x8, [sp, #320]
    0x102450c1c <+6020>: add x3, x8, x19
    0x102450c20 <+6024>: sub x0, x29, #184
    0x102450c24 <+6028>: sub x1, x29, #0000244
    0x102450c28 <+6032>: add x2, sp, #2956
    0x102450c2c <+6036>: sub x4, x29, #152
    0x102450c30 <+6040>: mov x5, x22
    0x102450c34 <+6044>: mov x6, x25
    0x102450c38 <+6048>: mov x7, x3
    0x102450c3c <+6052>: bl 0x102450e5c ; mma1noc_(double*, int*, int*, double*, double*, int*, int*, double*) at AdvApp2Var_ApproxF2var.cxx:1440
    0x102450c40 <+6056>: str wzr, [sp, #2956]
    0x102450c44 <+6060>: ldrsw x20, [x24]
    0x102450c48 <+6064>: cmp w20, #0000001
    0x102450c4c <+6068>: mov x9, x21
    0x102450c50 <+6072>: ldr x26, [sp, #0000176]
    0x102450c54 <+6076>: b.lt 0x102450cb4 ; <+6172> at AdvApp2Var_ApproxF2var.cxx:6625
    0x102450c58 <+6080>: movz x21, #0
    0x102450c5c <+6084>: ldr w8, [sp, #0000364]
    0x102450c60 <+6088>: add w8, w8, #0000001
    0x102450c64 <+6092>: mul w8, w9, w8
    0x102450c68 <+6096>: sxtw x8, w8
    0x102450c6c <+6100>: add x8, x8, #0000001
    0x102450c70 <+6104>: ldr x9, [sp, #472]
    0x102450c74 <+6108>: mul x8, x9, x8
    0x102450c78 <+6112>: ldr x9, [sp, #152]
    0x102450c7c <+6116>: add x19, x9, x8, lsl #3
    0x102450c80 <+6120>: sub x0, x29, #184
    0x102450c84 <+6124>: add x2, sp, #2956
    0x102450c88 <+6128>: sub x4, x29, #152
    0x102450c8c <+6132>: mov x1, x23
    0x102450c90 <+6136>: mov x3, x19
    0x102450c94 <+6140>: mov x5, x22
    0x102450c98 <+6144>: mov x6, x25
    0x102450c9c <+6148>: mov x7, x19
    0x102450ca0 <+6152>: bl 0x102450e5c ; mma1noc_(double*, int*, int*, double*, double*, int*, int*, double*) at AdvApp2Var_ApproxF2var.cxx:1440
    0x102450ca4 <+6156>: add x21, x21, #0000001
    0x102450ca8 <+6160>: add x19, x19, x26
    0x102450cac <+6164>: cmp x21, x20
    0x102450cb0 <+6168>: b.lt 0x102450c80 ; <+6120> at AdvApp2Var_ApproxF2var.cxx:6626
    0x102450cb4 <+6172>: ldr x9, [sp, #0000208]
    0x102450cb8 <+6176>: ldr w8, [x9]
    0x102450cbc <+6180>: add w2, w8, #0000001
    0x102450cc0 <+6184>: str w2, [x9]
    0x102450cc4 <+6188>: ldr x8, [sp, #272]
    0x102450cc8 <+6192>: cmp w8, w2
    0x102450ccc <+6196>: b.ne 0x10244f98c ; <+1268> at AdvApp2Var_ApproxF2var.cxx:6476
    0x102450cd0 <+6200>: b 0x102450d3c ; <+6308> at AdvApp2Var_ApproxF2var.cxx:6666
    0x102450cd4 <+6204>: ldr x20, [sp, #0000208]
    0x102450cd8 <+6208>: ldrsw x8, [x20]
    0x102450cdc <+6212>: ldr x9, [sp, #256]
    0x102450ce0 <+6216>: add x2, x9, x8, lsl #3
    0x102450ce4 <+6220>: mov x19, x2
    0x102450ce8 <+6224>: ldr d9, [x19, #0000008]!
    0x102450cec <+6228>: ldr d10, [x2], #0000016
    0x102450cf0 <+6232>: sub w8, w22, w8
    0x102450cf4 <+6236>: lsl w8, w8, #3
    0x102450cf8 <+6240>: stur w8, [x29, #-256]
    0x102450cfc <+6244>: sub x0, x29, #256
    0x102450d00 <+6248>: mov x1, x19
    0x102450d04 <+6252>: bl 0x10246dfcc ; AdvApp2Var_SysBase::mcrfill_ at AdvApp2Var_SysBase.cxx:2421
    0x102450d08 <+6256>: fadd d0, d10, d9
    0x102450d0c <+6260>: fmul d0, d0, d8
    0x102450d10 <+6264>: str d0, [x19]
    0x102450d14 <+6268>: add w22, w22, #0000001
    0x102450d18 <+6272>: str x22, [sp, #272]
    0x102450d1c <+6276>: ldr w2, [x20]
    0x102450d20 <+6280>: cmp w22, w2
    0x102450d24 <+6284>: mov x22, x21
    0x102450d28 <+6288>: b.ne 0x10244f98c ; <+1268> at AdvApp2Var_ApproxF2var.cxx:6476
    0x102450d2c <+6292>: b 0x102450d3c ; <+6308> at AdvApp2Var_ApproxF2var.cxx:6666
    0x102450d30 <+6296>: orr w8, wzr, #0x1
    0x102450d34 <+6300>: ldr x9, [sp, #552]
    0x102450d38 <+6304>: str w8, [x9]
    0x102450d3c <+6308>: ldr x8, [sp, #2960]
    0x102450d40 <+6312>: cbz x8, 0x102450d60 ; <+6344> at AdvApp2Var_ApproxF2var.cxx:6669
    0x102450d44 <+6316>: add x0, sp, #0000600
    0x102450d48 <+6320>: sub x1, x29, #0000240
    0x102450d4c <+6324>: add x2, sp, #2972
    0x102450d50 <+6328>: add x4, sp, #2960
    0x102450d54 <+6332>: add x5, sp, #2952
    0x102450d58 <+6336>: movz x3, #0
    0x102450d5c <+6340>: bl 0x10246d2e4 ; AdvApp2Var_SysBase::mcrdelt_ at AdvApp2Var_SysBase.cxx
    0x102450d60 <+6344>: ldr w8, [sp, #2952]
    0x102450d64 <+6348>: cmp w8, #0000001
    0x102450d68 <+6352>: b.lt 0x102450d7c ; <+6372> at AdvApp2Var_ApproxF2var.cxx:6678
    0x102450d6c <+6356>: movz w8, #0xd
    0x102450d70 <+6360>: ldr x9, [sp, #552]
    0x102450d74 <+6364>: str w8, [x9]
    0x102450d78 <+6368>: b 0x102450d88 ; <+6384> at AdvApp2Var_ApproxF2var.cxx:6679
    0x102450d7c <+6372>: ldr x8, [sp, #552]
    0x102450d80 <+6376>: ldr w8, [x8]
    0x102450d84 <+6380>: cbz w8, 0x102450d9c ; <+6404> at AdvApp2Var_ApproxF2var.cxx:6681
    0x102450d88 <+6384>: adrp x0, 650
    0x102450d8c <+6388>: add x0, x0, #821
    0x102450d90 <+6392>: orr w2, wzr, #0x7
    0x102450d94 <+6396>: ldr x1, [sp, #552]
    0x102450d98 <+6400>: bl 0x10246d588 ; AdvApp2Var_SysBase::maermsg_ at AdvApp2Var_SysBase.cxx:1153
    0x102450d9c <+6404>: ldr w8, [sp, #508]
    0x102450da0 <+6408>: cmp w8, #0000002
    0x102450da4 <+6412>: b.lt 0x102450db8 ; <+6432> at AdvApp2Var_ApproxF2var.cxx:6682
    0x102450da8 <+6416>: adrp x0, 650
    0x102450dac <+6420>: add x0, x0, #821
    0x102450db0 <+6424>: orr w1, wzr, #0x7
    0x102450db4 <+6428>: bl 0x10246e20c ; AdvApp2Var_SysBase::mgsomsg_ at AdvApp2Var_SysBase.cxx:3040
    0x102450db8 <+6432>: add x0, sp, #0000600
    0x102450dbc <+6436>: bl 0x10246cf70 ; AdvApp2Var_SysBase::~AdvApp2Var_SysBase at AdvApp2Var_SysBase.cxx:147
    0x102450dc0 <+6440>: ldur x8, [x29, #-120]
    0x102450dc4 <+6444>: adrp x9, 909
    0x102450dc8 <+6448>: ldr x9, [x9, #1680]
    0x102450dcc <+6452>: ldr x9, [x9]
    0x102450dd0 <+6456>: sub x8, x9, x8
    0x102450dd4 <+6460>: cbnz x8, 0x102450e38 ; <+6560> at AdvApp2Var_ApproxF2var.cxx:6685
    0x102450dd8 <+6464>: movz w0, #0
    0x102450ddc <+6468>: sub sp, x29, #0000112
    0x102450de0 <+6472>: ldp x29, x30, [sp, #0000112]
    0x102450de4 <+6476>: ldp x20, x19, [sp, #96]
    0x102450de8 <+6480>: ldp x22, x21, [sp, #80]
    0x102450dec <+6484>: ldp x24, x23, [sp, #64]
    0x102450df0 <+6488>: ldp x26, x25, [sp, #48]
    0x102450df4 <+6492>: ldp x28, x27, [sp, #32]
    0x102450df8 <+6496>: ldp d9, d8, [sp, #0000016]
    0x102450dfc <+6500>: ldp d11, d10, [sp], #0000128
    0x102450e00 <+6504>: ret
    0x102450e04 <+6508>: brk #0x1
    0x102450e08 <+6512>: b 0x102450e24 ; <+6540> at AdvApp2Var_ApproxF2var.cxx:6685
    0x102450e0c <+6516>: b 0x102450e24 ; <+6540> at AdvApp2Var_ApproxF2var.cxx:6685
    0x102450e10 <+6520>: b 0x102450e24 ; <+6540> at AdvApp2Var_ApproxF2var.cxx:6685
    0x102450e14 <+6524>: b 0x102450e24 ; <+6540> at AdvApp2Var_ApproxF2var.cxx:6685
    0x102450e18 <+6528>: b 0x102450e24 ; <+6540> at AdvApp2Var_ApproxF2var.cxx:6685
    0x102450e1c <+6532>: b 0x102450e24 ; <+6540> at AdvApp2Var_ApproxF2var.cxx:6685
    0x102450e20 <+6536>: b 0x102450e24 ; <+6540> at AdvApp2Var_ApproxF2var.cxx:6685
    0x102450e24 <+6540>: mov x19, x0
    0x102450e28 <+6544>: add x0, sp, #0000600
    0x102450e2c <+6548>: bl 0x10246cf70 ; AdvApp2Var_SysBase::~AdvApp2Var_SysBase at AdvApp2Var_SysBase.cxx:147
    0x102450e30 <+6552>: mov x0, x19
    0x102450e34 <+6556>: bl 0x1026956f4 ; symbol stub for: _Unwind_Resume
    0x102450e38 <+6560>: bl 0x102695724 ; symbol stub for: __stack_chk_fail
    0x102450e3c <+6564>: brk #0x1
    0x102450e40 <+6568>: b 0x102450e24 ; <+6540> at AdvApp2Var_ApproxF2var.cxx:6685
    0x102450e44 <+6572>: b 0x102450e24 ; <+6540> at AdvApp2Var_ApproxF2var.cxx:6685
-> 0x102450e48 <+6576>: brk #0x1
    0x102450e4c <+6580>: b 0x102450e24 ; <+6540> at AdvApp2Var_ApproxF2var.cxx:6685
    0x102450e50 <+6584>: b 0x102450e24 ; <+6540> at AdvApp2Var_ApproxF2var.cxx:6685
    0x102450e54 <+6588>: brk #0x1
    0x102450e58 <+6592>: b 0x102450e24 ; <+6540> at AdvApp2Var_ApproxF2var.cxx:6685
08Commenter 8
Which version correspond the lines of source code to?
09Author
Master branch
10Commenter 10
For which edge number does the crash occur?
11Author
No. 21 (if the first one is 1)
12Author
Also occurs for 37, 47, 50

Here is the code, with the skipped edges:

    std::ifstream file("[user path removed]/Desktop/Attachment 1 (BREP)");
    TopoDS_Shape shape;
    BRep_Builder b;
    BRepTools::Read(shape, file, b);
    int i = 1;
    for (TopExp_Explorer exp(shape, TopAbs_EDGE); exp.More(); exp.Next())
    {
        if (i == 21 || i == 37 || i == 47 || i == 50)
        {
            ++i;
            continue;
        }
        try
        {
            std::cout << std::endl << "INDEX: " << i << std::endl;
            std::cout.flush();
            BRepFilletAPI_MakeFillet filletMaker(shape);
            filletMaker.Add(0.165405, TopoDS::Edge(exp.Current()));
            filletMaker.Build();
        }
        catch (...)
        {
        }
        ++i;

    }
13Commenter 13
I have inspected the source code visually, and dynamically with Intel Inspector. No problems were found.
I have no possibility to debug it on Mac or iOS.
14Author
Can you test it with Clang on Windows?
15Commenter 15
I have no possibility to go deeper in this bug. Please refer to OCC support if you need it to be fixed.
16Commenter 2
I actually see the same error when trying to build a simple planar surface with BRepFill_Filling with clang on Mac. Works fine with gcc on Linux.

Here is the stack trace:

thread #0000001: tid = 0x98f6d, 0x0000000103bbe25b simvascular`AdvApp2Var_ApproxF2var::mma2fnc_(int*, int*, int*, double*, AdvApp2Var_EvaluatorFunc2Var const&, double*, int*, int*, double*, int*, int*, int*, int*, int*, double*, int*, double*, int*, double*, double*, double*, double*, double*, double*, double*, int*) + 8331, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
  * frame #0: 0x0000000103bbe25b simvascular`AdvApp2Var_ApproxF2var::mma2fnc_(int*, int*, int*, double*, AdvApp2Var_EvaluatorFunc2Var const&, double*, int*, int*, double*, int*, int*, int*, int*, int*, double*, int*, double*, int*, double*, double*, double*, double*, double*, double*, double*, int*) + 8331
    frame #0000001: 0x0000000103bc6467 simvascular`AdvApp2Var_Iso::MakeApprox(AdvApp2Var_Context const&, double, double, double, double, AdvApp2Var_EvaluatorFunc2Var const&, AdvApp2Var_Node&, AdvApp2Var_Node&) + 3111
    frame #0000002: 0x0000000103bafabd simvascular`AdvApp2Var_ApproxAFunc2Var::ComputeConstraints(AdvApprox_Cutting const&, AdvApprox_Cutting const&, AdvApp2Var_EvaluatorFunc2Var const&, AdvApp2Var_Criterion const&) + 765
    frame #3: 0x0000000103bae8d6 simvascular`AdvApp2Var_ApproxAFunc2Var::ComputePatches(AdvApprox_Cutting const&, AdvApprox_Cutting const&, AdvApp2Var_EvaluatorFunc2Var const&, AdvApp2Var_Criterion const&) + 454
    frame #4: 0x0000000103bac937 simvascular`AdvApp2Var_ApproxAFunc2Var::Perform(AdvApprox_Cutting const&, AdvApprox_Cutting const&, AdvApp2Var_EvaluatorFunc2Var const&, AdvApp2Var_Criterion const&) + 23
    frame #5: 0x0000000103bac48d simvascular`AdvApp2Var_ApproxAFunc2Var::AdvApp2Var_ApproxAFunc2Var(int, int, int, opencascade::handle<TColStd_HArray1OfReal> const&, opencascade::handle<TColStd_HArray1OfReal> const&, opencascade::handle<TColStd_HArray1OfReal> const&, opencascade::handle<TColStd_HArray2OfReal> const&, opencascade::handle<TColStd_HArray2OfReal> const&, opencascade::handle<TColStd_HArray2OfReal> const&, double, double, double, double, GeomAbs_IsoType, GeomAbs_Shape, GeomAbs_Shape, int, int, int, int, AdvApp2Var_EvaluatorFunc2Var const&, AdvApp2Var_Criterion const&, AdvApprox_Cutting&, AdvApprox_Cutting&) + 525
    frame #6: 0x0000000103eb7db3 simvascular`GeomPlate_MakeApprox::GeomPlate_MakeApprox(opencascade::handle<GeomPlate_Surface> const&, AdvApp2Var_Criterion const&, double, int, int, GeomAbs_Shape, double) + 1219
    frame #0000007: 0x000000010443baa1 simvascular`BRepFill_Filling::Build() + 2849
17Author
Same here. We should try to separate the issue, to figure out whether it is a compiler bug, or the problem is in OCCT. Especially considering that Microsoft Visual C++ is also switching to Clang (at least the compiler frontend, http://blogs.msdn.com/b/vcblog/archive/2015/05/01/bringing-clang-to-windows.aspx)
18Commenter 2
Sounds good. I am trying to compile occt with gcc on mac currently but having problems.

19Commenter 19
Please test this case on Mac with current master
20Author
Still crashes with current master.
21Author
Tested with the current master, on Mac OSX and iOS with the latest Clang, still crashes.

22Commenter 3
We also reproduced the same issue with same stack on other workloads involving approximation and AdvApp2Var. Did the OCC team managed to reproduce the issue ?
23Author
@Roman as a workaround we set the optimization level of the problematic file to -O1
24Author
This crash is gone with the latest release of Xcode.
25Commenter 3
FYI.
We work-around the issue by using __attribute__ ((noinline)) on static functions in AdvApp2Var_ApproxF2var.cxx when compiling by clang.
26Commenter 4
Coming in late, but I'll add my 2 cents: this is a Clang problem, not an OCCT problem. The giveaway is the ud2 instruction. Clang stupidly generates bad instructions (ud2) when it gets upset about what it thinks is undefined behavior. This has been an issue in OCE for a while because tons of the tests in the test suite pass when compiled with MSVC or GCC, but not with Clang. This started with Clang 3.4 or so, I don't remember exactly, but it's definitely the problem. Very annoying.
27Commenter 5
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: Martin Siggel
Date: Mon May 30 22:47:13 2016 +0200

    0026778: BRepFilletAPI_MakeFillet crash
    
    Fixed crash on OS X due to clang compiler errors
    
    I implemented Commenter 3's workaround described in
    OCCT Mantis 0026778.
28Commenter 28
I have pushed fix made by Martin Siggel in OCE to branch CR26778, please test

29Commenter 29
Dear Commenter 1,
Branch CR266778 from occt git-repository (and IR-2016-06-02 from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested on Release mode.
[revision removed]

Number of compiler warnings:

occt component :
Linux: 0 (0 on master)
Windows: 0 (0 on master)
MacOS : 0 (0 on master)

products component :
Linux: 72 (72 on master)
Windows: 4 (4 on master)
MacOS : 1158

Regressions/Differences/Improvements:
No regressions/differences

Testing cases:
Not needed

Testing on Linux:
occt component :
Total MEMORY difference: 88998704 / 88758535 [+0.27%]
Total CPU difference: 19491.229999999916 / 19848.729999999934 [-1.80%]
products component :
Total MEMORY difference: 27627935 / 27628608 [-0.00%]
Total CPU difference: 5140.9899999999725 / 5165.599999999994 [-0.48%]

Testing on Windows:
occt component :
Total MEMORY difference: 55965758 / 55963422 [+0.00%]
Total CPU difference: 18212.18074399881 / 18468.958389998854 [-1.39%]
products component :
Total MEMORY difference: 18749006 / 18714334 [+0.19%]
Total CPU difference: 5010.486918299949 / 5029.363039299948 [-0.38%]

There are no differences in images found by testdiff.
30Commenter 30
Dear Commenter 1,
Branch CR266778 is TESTED.
31Commenter 6
+// Workaround a clang compiler bug which creates
+// invalid instructions on OS X. This workaround
+// was proposed by Commenter 3.
+#ifdef __clang__
+  #define NO_INLINE __attribute__ ((noinline))
+#else
+  #define NO_INLINE
+#endif

Name for the macros "NO_INLINE" is too generous - it can be easily go into conflict with external macros and does not follow OCCT coding rules.
In general, it makes sense defining global Standard_NOINLINE macros and define alias in AdvApp2Var_ApproxF2var.cxx for clang only with proper description.

The comments and description in commit look too opaque - it provides useless references and does not declare which version of clang is confirmed to be broken - so it will be more difficult to check later if workaround is still needed or not. Test case should included into the patch.

Note that in general it is better reporting compiler bugs to their developers - otherwise issue might be kept hidden in other places and affect other projects.
32Commenter 6
> Tested with the current master, on Mac OSX and iOS with the latest Clang, still crashes.
no crash with XCode 6.4
$ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.5.0
Thread model: posix

So from the timeline I suppose the problem comes with XCode 7.0-7.2 (and probably later - but should be checked).

33Commenter 6
No crash on XCode 7.3.1 (7D1014)
$ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Could you please check that the problem is still reproducible for you on updated XCode?

34Author
The issue is fixed with the latest Xcode.
35Commenter 6
Dear bumaster,

please close the issue as no change required.
36Commenter 5
Branch [archived branch] has been deleted by Participant.

[revision removed]

Related records