BRepAlgoAPI_Cut -> SimplifyResult -> Crash!

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?

Dmitrii Pasukhin's picture

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, Dmitrii.

Caleb Smith's picture

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.

Dmitrii Pasukhin's picture

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, Dmitrii.

Caleb Smith's picture

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...

Thomas Anderson's picture

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?

Caleb Smith's picture

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

Caleb Smith's picture

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 gitolite@git.dev.opencascade.org:occt occt
Cloning into 'occt'...
gitolite@git.dev.opencascade.org: Permission denied (publickey).
fatal: Could not read from remote repository.

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

Dmitrii Pasukhin's picture

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, Dmitrii.

 

Caleb Smith's picture

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!