DiscussionsIssue archiveOCCT:Modeling Algorithms

Archived issue #0026929

Extrema_ECC hang/crash

CommunityOCCT:Modeling Algorithmsclosed31 public notes

Search issues

Description

See the attached code. In this case it hangs, but in some similar cases it crashed.

Hang/crash occurs at Extrema_GenExtCC.gxx #0000291:

std::sort(aPnts.begin(), aPnts.end(), comp);

Steps to reproduce

test bugs modalg_6 bug26929

Public activity

31 archived notes

Participants are labeled by their role within this record.

01Commenter 1
Dear Alexander, please look at this issue and estimate if it has a very simple solution to be integrated in 7.0. Otherwise, change target version to 7.1.
02Commenter 2
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: aml
Date: Wed Nov 25 22:49:03 2015 +0300

    0026929: Extrema_ECC hang/crash
    
    Test case added.
03Commenter 3
Shapes were converted into "restore" format and attached. Test case added.
04Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
05Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
06Commenter 6
Dear msv,
This problem not reproduced on the following configurations:
vc11-x64 Release / Debug
vc10-x64 Release / Debug

So, test case was created. Could you please review my modifications?
07Commenter 7
I guess the problem was reported on OS X or iOS, and can be specific to this platform and/or CLang compiler. Istvan, can you please specify the configuration where you observe the problem (OCCT version / commit hash, OS, compiler)?
08Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
09Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
10Commenter 10
I have reviewed test case.

Dear Istvan, could you please try to run the test script from the branch CR26929 within your configuration to make sure it reproduces the problem?
11Author
Unfortunately I can not run tcl scripts on iOS, but based on the code it should.
12Commenter 12
What about OS X then?
13Author
I don't have MacOSX binaries, but I will compile them tomorrow morning.
14Author
OCCT version: latest master, Clang, Xcode 7.1
15Author
But this one is not related to Clang optimizations, because it hangs in debug mode as well.
16Author
Well, I can not even compile the master branch on OSX, TKernel compilation fails with linker error to std::bad_cast.
17Author
Finally I compiled on OSX, but DRAWEXE crashes with
libc++abi.dylib: terminating with uncaught exception of type Standard_DomainError
Abort trap: 6
18Commenter 18
Dear Commenter 1, could you check the test case in this branch on MacOSX?
19Commenter 1
MacOS master

test script crashed by CPU limit 100 and 300. See attached Attachment 1 (TXT) file
20Author
Easy to fix: just add these three lines to the comparator code

if (theA.X() == theB.X() && theA.Y() == theB.Y())
    {
        return &theA < &theB
    }
21Commenter 21
I do not like this solution. The performance will depend on ordering of objects in memory. We in OCCT try to avoid such behavior as much as possible.
I think it is ill implementation of std::sort in CLang.
22Commenter 22
Istvan, thank you for highlighting the problem! Can you try another fix: just replace "<=" by "<" at line 39:

> if (theA.Y() <= theB.Y())

Here the point is that operator 'less' may not return true for equal objects
23Commenter 2
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: msv
Date: Sat Mar 26 20:42:49 2016 +0300

    Experimental change: make comparator returning false in the case of equal elements.

Author: aml
Date: Wed Nov 25 22:49:03 2015 +0300

    0026929: Extrema_ECC hang/crash
    
    Test case added.
24Commenter 24
Hi Istvan,
Could you test this problem on the branch CR26929_1?
Mikhail
25Commenter 25
I have tested this change on a set of tests "bugs mod*", no regressions have been revealed.
26Commenter 2
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: msv
Date: Sat Mar 26 20:42:49 2016 +0300

    0026929: Extrema_ECC hang/crash
    
    Comparator functor corrected to return false in the case of equal elements.
    Test case added.
27Commenter 27
Igor, please compile branch CR26929 on OS X and check test bugs modalg_6 bug26929
28Commenter 28
Sorry, correct branch is indeed CR26929_2
29Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
30Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
31Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]