Hello,
I’m currently working on a third party c++ library, that I use in a c++ unreal editor plugin.
It’s integrated as a library, the plugin linking with it :
PublicAdditionalLibraries.AddRange(
new string[]
{
Path.Combine(libPath, "MyLib.lib")
}
);
PublicRuntimeLibraryPaths.AddRange(
new string[]
{
Path.Combine(LibPath, "MyLib.dll")
}
);
I have a crash problem when allocating/deleting a library class instance in the plugin. It crashes as soon as there is a constructor defined in cpp (in the library assembly, won’t crash if inlined in the .h), and there is a virtual destructor.
Here the minimum code to reproduce it :
In the library .h :
class Test
{
public:
virtual ~Test() = default;
Test();
};
In the library .cpp :
Test::Test()
{
}
In the unreal plugin :
Test * test = new Test();
delete test; // << __debugbreak() happens here
It seems to be a heap corruption.
Can it be an incompatibility between the binary version of unreal engine 5.4.1 (I don’t built it myself), and the last visual studio 2022 I use to build my projects? What should I do to get this working ?