Crash using BRepAlgoAPI_Common in Multithreading

Hello everyone,

I'm trying to do overlap detections on 3D models utilizing BRepAlgoAPI_Common with OpenCascade 7.8.1.
To enhance efficiency, I've ventured into running these computations within a multithreaded environment.
Rather than utilizing SetRunParallel to process a single BRepAlgoAPI_Common in multiple threads, I've opted for employing numerous BRepAlgoAPI_Common within each thread.

To ensure data integrity, I've encapsulated my TopoDS_Shapes within mutexes to prevent concurrent access.

However, I've encountered crashes with certain models. I've attempted to protect the TopoDS_TShape instead of the TopoDS_Shapes, yet the crashes persist.

Is BRepAlgoAPI_Common inherently thread-safe, or are there known challenges when employing it within a multithreaded context ?

Thank you!

Best Regards

Charles Meyer

Dmitrii Pasukhin's picture

Hello, if operation take impact on original Face, for sure, it will be data raysing.

For avoid that you need to make deep clone original shape. And after that match before/after with ReShape and history of clone operation.

Best regards, Dmitrii.

charles meyer's picture

Hello Dmitrii,

Thank you for your quick answer.

I tried to make deep clone with BRepBuilderAPI_Copy but i still got the crash.
Is that the good way to deep clone a shape ?

Thanks

Dmitrii Pasukhin's picture

It is only one way if you have no option to control data sharing behavior.

I have no idea why you have crash... Do you copy geometry too? Which level you split your common operation? Face level? Solid level?

Best regards, Dmitrii.

charles meyer's picture

I am copying the shape at the solid level.

Is there a specific detail or subtlety we might be missing that could explain why the crash is still occurring?

Thanks again for your help.

Best regards,

Charles Meyer

Dmitrii Pasukhin's picture

When you using copy tool. BRepBuilderAPI_Copy you need to specificy any arguments to true.

Best regards, Dmitrii.

charles meyer's picture

It turns out that my issue was due to having compiled OCCT with the BUILD_RELEASE_DISABLE_EXCEPTIONS flag set to ON.
After recompiling with this flag set to OFF, I no longer experience crashes.

Thanks again for your help.

Best regards, Charles Meyer