Ecos-platform/FMU4j

String parameter

jay2310a opened this issue · 2 comments

Hi there!

When using a string as parameter the FMU crashes Matlab with a protection fault AFTER simulation is done (without unexpected results) at the exit of the terminate() methode. It seems to be related to some clearStrBuffer() / onClose() code...

PARAMETER:

@ScalarVariable(causality = Fmi2Causality.parameter, variability = Fmi2Variability.fixed)
private String stringParam="abc";

CRASH:

ntdll.dll+00287835 RtlFreeHeap+00000843
MSVCR100.dll+00429460 free+00000028
jvm.dll+01317521 JNI_GetCreatedJavaVMs+00016689
JavaSlave2.dll+00051390 fmu4j::SlaveInstance::clearStrBuffer+00000078
JavaSlave2.dll+00041916 std::locale::facet::_Decref+00000716
JavaSlave2.dll+00057882 fmu4j::SlaveInstance::onClose+00000154
JavaSlave2.dll+00027343 fmu4j::SlaveInstance::~SlaveInstance+00000063
JavaSlave2.dll+00033780 std::basic_ifstream<char,std::char_traits >::`vbase destructor'+00000852
JavaSlave2.dll+00043017 std::locale::facet::_Decref+00001817
JavaSlave2.dll+00005140 cppfmu::detail::CanFind<std::vector<std::basic_string<char,std::char_traits,cppfmu::Allocator >,cppfmu::Allocator<std::basic_string<char,std::char_traits,cppfmu::Allocator > > >,char const * __ptr64>+00000212

Any ideas would be greatly apreciated!
Regards, Jay

Not sure if I will ever be able to look into this. But it would be nice to know if this is specific to MATLAB? Have you tried other importers?

Your best bet would be trying to modify the native code. Perhaps commenting out this line at the cost of a minor memory leak.

Thank you!

It took a while to figure out how to build and use the binaries but now it works when just commenting out the line.
I will try to look into this deeper and come back with any insight...

Regards, J