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->Delete();
      entity = 0;
    }
entity->Delete();

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?

Ege Sekkin's picture

update:
I confirmed that changing the order of the files in CMakeLists.txt makes another one throw the same error - I think the library tires to dereference twice as they both unload.
if the order is TKXDESTEP;TKXSBase : TKXSBase throws the error. and if the order is reversed: TKXDESTEP throws the error.

Kirill Gavrilov's picture

I built a debug version and the call stack points to TKXSBase.dll

You have forgotten to attach your call stack, as currently your message shows only a function from TKernel and used everywhere in OCCT.

This happens after I import a model and shut down the host application
...
if the order is TKXDESTEP;TKXSBase : TKXSBase throws the error. and if the order is reversed: TKXDESTEP throws the error.

What exactly does it mean? Are you loading some DLL's dynamically (how then?), or just call a straightforward code? How does library order may affect anything?

Mikhail Sazonov's picture

This forum is not relevant for this post. The right place is https://dev.opencascade.org/forums/data-exchange-and-application-framework.

Ege Sekkin's picture

Okay I will repost in that channel with further comments, thank you!