Crash on NCollection_BaseAllocator::Free

I use OCCT6.6 in my mfc project. Boolean operatoions are used, the codes are like this:
TopoDS_Shape box1 = BRepPrimAPI_MakeBox(30, 30, 30);
TopoDS_Shape box2 = BRepPrimAPI_MakeBox(gp_Pnt(0, 0, 10), 30, 30, 10);
box1 = BRepAlgoAPI_Cut(box1, box2);

a crash cased in BRepAlgoAPI_Cut which comes from NCollection_BaseAllocator::Free.
what's wrong about it?
Thx!

Pawel's picture

Hello Tom,

are you using 64bit Win7?

If so, there seems to be a problem with this configuration when using BOPs, see:

http://tracker.dev.opencascade.org/view.php?id=23855

Pawel

Thomas Rabenbauer's picture

Hello Pawel,
Yes, i'm using 64bit Win7,is there any ways to fix this?
Thx!

Thomas Rabenbauer's picture

FYI, i test my code in an empty project(not mfc), and it work well.

Pawel's picture

Do you use TBB? If so try disabling it (MMGT_OPT = 0 instead of MMGT_OPT = 2) - it helped in my case.

Thomas Rabenbauer's picture

Where do i find the MMGT_OPT?

Pawel's picture

MMGT_OPT can be set using batch files or globally for the system. If it's not set then OCCT assumes it is '0'. But in the latter case your problem is other that the one reported as issue 23855...

Thomas Rabenbauer's picture

Hello Pawel,
I add MMGT_OPT in environment variable and set to 1. But still there comes a error.
This time Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "") case the problem in gp_Dir2d::gp_Dir2d

Thomas Rabenbauer's picture

when i set MMGT_OPT to 1, does OCCT still need tbb?
when i remove tbb libs and dlls, the project cannot run any more and tells that lose tbb lib

Forum supervisor's picture

Dear Tom,
If you don't need TBB at all you may rebuild OCCT defining variable HAVE_TBB as presented below:
set HAVE_TBB=false
Regards

Thomas Rabenbauer's picture

Hi, Pawel
By the way, what's difference between BRepAlgo_Cut and BRepAlgoAPI_Cut ?
Thx!

Pawel's picture

Hi Tom,

- BRepAlgo_Cut is the old API (not really actively maintained, as I understand), BRepAlgoAPI_Cut is the new/current one

- if OCCT is compiled against TBB you still need the dlls to run although the do not get called

- I just ran a small script in DRAW to test your case:

box b1 30 30 30
box b2 0 0 10 30 30 10
cut result b1 b2

and I can't observe any problem with it...

Pawel

Pawel's picture

... oops, I used the old BOP (BRepAlgo_Cut) in the sample script.

the script should read:

box b1 30 30 30
box b2 0 0 10 30 30 10
bop b1 b2
bopcut result_new

Thomas Rabenbauer's picture

Hello Pawel, i finaly found out the answer. I use D3D as render context, the D3D changes floating-point control word, so jst reset it. Anyway, Thank you very much!