Crash during initialization of c++ clib object.
Show older comments
Hello All,
I am building a custom visual studio dll and I generate a clib interface to it using the interfaceGeneration routines.
I am using MATLAB 2023a with visual studio 2019.
I have a custom c++ class (called DeviceInfo) that is a inherted class from a simple HardwareInfo class.
Internally (in the cpp) this class checks some shared pointers that the DeviceInfo object owns and free them if nessecary in its destructor. (that are all alocated internally in the cpp) among these are thread objects.
If I build the dll in RelWithDebInfo. I can use visual studio to attach to the matlabclibhost and do some basic debugging. I am getting seg faults sometimes when I create/delete a DeviceInfo object from matlab. I also am getting heap corruption error from the visual studio debugger.
Critical error detected c0000374
A breakpoint instruction (__debugbreak() statement or a similar call) was executed in MATLABCLibHost.exe.
Exception thrown at 0x00007FFFFCF1C7A9 (ntdll.dll) in MATLABCLibHost.exe: 0xC0000374: A heap has been corrupted (parameters: 0x00007FFFFCF938A0).
Unhandled exception at 0x00007FFFFCF1C7A9 (ntdll.dll) in MATLABCLibHost.exe: 0xC0000374: A heap has been corrupted (parameters: 0x00007FFFFCF938A0).
Exception thrown: read access violation.
**_Left** was 0xFFFFFFFFFFFFFFFF.
usage MATLAB code:
testDevice = clib.ImatestControl.ControlAPI.DummyDeviceInfo
testDevice = clib.ImatestControl.ControlAPI.DummyDeviceInfo %<---destructor should be called on the 1st instance here
Any Help/Hints would be appreciated.
Thanks,
Trevor
Accepted Answer
More Answers (0)
Categories
Find more on Build MATLAB Interface to C++ Library in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!