Forum archiveIssue archiveModeling Data and Algorithms

Archived discussion

BRepAlgoAPI_Cut -> SimplifyResult -> Crash!

Modeling Data and AlgorithmsThu, 02/01/2024 - 22:4110 replies

Browse this forum
QuestionAuthor

Hi geniuses! ;)

This code:

BRepAlgoAPI_Cut* cut = new BRepAlgoAPI_Cut(initialShape, appliedShape);
if (!cut->IsDone())
    return false; 

cut->SimplifyResult();

sometimes just crash with access violation like this:

Exception thrown at 0x00007FFB21102D12 (TKBRep.dll) in cad.exe: 0xC0000005: Access violation writing location 0x0000000000000038.

How i can to avoid this crash and not kill all programm? Maybe i can catch some kind of signal or somehow pre-check that this algorithm will crash or that this algorithm does not have enough data... I don’t even know... Is it possible to somehow pre-prepare for this crash so that my function of extrusion/cut just return false, and not crash the entire software?

Discussion

10 archived replies

Posts are displayed in their archived order.

01Commenter-1

Hello, unfortunately we don't be able to help you with out a sample or file. Could you share?

Byt yes, you can use try/catch code on your side. Disabling exceptions not helps with unexpected acess.

Best regards, Commenter-1.

02Author

Dmitrii, hi!
It's very difficult to extract individual OCCT models from my CAD. Okay, I'll debug OCCT itself, I think it's just a bug inside, because this is not a regular exception that OCCT would specifically throw, this is a stupid attempt to write to a deleted pointer, that is, this is a bug.

03Commenter-1

Any TopoDS_Shape be able to exported into ".brep" format.

BRepTools::Write

Additionally, try{ code } catch(...) { code } can help. But not always. The best thing is resolve the bug.

Best regards, Commenter-1.

04Author

Dmitrii,

Additionally, try{ code } catch(...) { code } can help. But not always. The best thing is resolve the bug.

Access violation - fatal exception, try catch won't help here...

Any TopoDS_Shape be able to exported into ".brep" format.

BRepTools::Write

Hmm... ok, I caught the fall situation on two simple donuts, here they are in attachment (argument_shape.brep - this is the original solid body from which I want to cut out tool_shape.brep body with BRepAlgoAPI_Cut and after SimplifyResult() [access violation] ).

Hmm.. how can this help resolve the problem? Well, I see that the tool body does not have triangulation, but this is unlikely to be the case...

05Commenter-2

I can't not duplicate your crash here on debian bookworm with occt 7.8.0. It is strange that a crash would occur in SimplifyResult as there is nothing to simplify from that boolean operation. Maybe you are mixing debug and release builds on windows?

06Author

Hey man, where did you get 7.8.0 version? What is the correct link to the latest version of the sources on GitHub? This one? https://github.com/Open-Cascade-SAS/OCCT

07Commenter-1
08Author

Thanks! I knew he was the one! But tell me please, why can’t I clone the latest sources from the official repository? Is access only available to contributors?

c:\OCCT>git clone [email removed]:occt occt
Cloning into 'occt'...
[email removed]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

09Commenter-1

To load from our git you must to register your SSH key into dev portal in your profile.

To load anonimus you needs to read the next page: https://dev.opencascade.org/resources/git_repository

Best regards, Commenter-1.

 

10Author

Guys, good news!
I completely updated my soft to OCCT 7.8.0 (was 7.7.* i think, I build it a long time ago, I don’t even remember) and this bug with ACCESS VIOLATION at SimplifyResult() just disappeared!
Now everything works like a charm :)
Cool!
Thanks everyone for the information!