TKXSBase.dll crash on shutdown when unloading

    //! Decrement reference counter and if 0, destroy referred object
    void EndScope()
      if (entity != 0 && entity->DecrementRefCounter() == 0)
      entity = 0;

This line throws a null pointer on shutdown:

Exception thrown: read access violation.
this->entity-> was 0x7FFF4ECAF808.

I am using ver 7.5.0. This happens after I import a model and shut down the host application. I built a debug version and the call stack points to TKXSBase.dll Any ideas how to avoid the crash?

Note: I am loading the DLLs dynamically and I confirmed that changing the order of the files in CMakeLists.txt when building the project makes another file throw the same error - I think the library tires to dereference twice as they both unload.

If the order in the list is TKXDESTEP;TKXSBase : TKXSBase throws the error. and if the order is reversed: TKXDESTEP throws the error. (I think this would just changes the order in which they are unloaded.)

Mikhail MPV's picture

Dear Ege,

Could you provide to us the whole call-stack of the exception to let us understand which object is deleted in the "EndScope" method? Also, what is the minimal set of operations with OCCT libraries in your application causes crash on shut down? Which OCCT version do you use?

Ege Sekkin's picture

Hello Mikhail,

I am using ver 7.5.0.

We load the file using STEPCAFControl_Reader. Then we use XCAFDoc_DocumentTool tools to collect shapes, sub-shapes, identify instances, and assembly structures. (including color, transform, layer info). Then we mesh things using BRepMesh_IncrementalMesh and parameters.

The crash happens when closing the host application after importing a step file. I will repro the crash and post a call stack shortly. 

Thank you for the help.

Ege Sekkin's picture

here's a partial log after the crash: