Using OpenCascade in a DLL

Hi,

we're writing a module that uses OpenCascade 7.2 in a dynamic loaded DLL.

This module simply reads a STEP or IGES using STEPCAFControl_Reader and IGESCADControl_Reader.

All works but unloading DLL I have an Unhandled exception (Access violation) in

     TKXSBase.dll!StepData_GlobalNodeOfWriterLib::~StepData_GlobalNodeOfWriterLib()    C++
     TKXSBase.dll!StepData_GlobalNodeOfWriterLib::`scalar deleting destructor'(unsigned int)    C++
     TKXSBase.dll!StepData_GlobalNodeOfWriterLib::~StepData_GlobalNodeOfWriterLib()    C++
     TKXSBase.dll!StepData_GlobalNodeOfWriterLib::`scalar deleting destructor'(unsigned int)    C++
     TKXSBase.dll!`dynamic atexit destructor for 'theglobal''()    C++
>    TKXSBase.dll!_CRT_INIT(void * hDllHandle, unsigned long dwReason, void * lpreserved) Line 416    C
     TKXSBase.dll!__DllMainCRTStartup(void * hDllHandle=0x00007ffce46a0000, unsigned long dwReason=0, void * lpreserved=0x00000056e81fea80) Line 522    C

it happens everytime I declare an object STEPCAFControl_Reader or IGESCAFControl_Reader. It happens also if the only code executed by DLL is a declaration like

STEPCAFControl_Reader reader;

Same code in an EXE works fine without problem.

Someone have an Idea?

I attached wizard generated solution (Vs 2012) to test it.

Thank you

Attachments: 
boris.sunik_142083's picture

Hi,

We have exactly the same problem. Any suggestions were appreciated

renato gasoto's picture

Hi,

I too have exactly the same problem. 

One interesting thing I noticed, if I set the order of the libraries on CMakeLists differently, the access violation happens at a different library. Depending on which is loaded first, the error happens either on TKXSBase.dll or TKXDESTEP.dll. Both at StandardHandle::EndScope;

My suspicion is that there is a race condition happening when deleting pointers on shutdown.

Any plan on when this problem will be addressed?

Kirill Gavrilov's picture

Any plan on when this problem will be addressed?

If analysis shows that the problem is within OCCT itself, then as first step it is necessary reporting an issue on Bugtracker (with a reproducer).
And suggestions or patches fixing the issue are welcome, of course.