I've been off programming Nim for a while. Now I was revisiting and old project
and I am hitting a failure I don't know how to address.
I am creating a library in Linux: `inc.so` which complies with the FMU standard
(I was doing this about 2 years ago).
The code compiles fine, but when I pass the library through the FMU checker I
get the following error:
[...]
0x7fc4aed10060"(r: ..., i: ..., b: ..., s: ..., isPositive: ..., time: 0.0,
instanceName: Test FMI 2.0 ME, type: fmi2ModelExchange, GUID:
{8c4e810f-3df3-4a00-8276-176fa3c9f008}, functions: ..., loggingOn: 1,
logCategories: [1, 1, 1, 1], componentEnvironment: ..., state:
modelInstantiated, eventInfo: (newDiscreteStatesNeeded: 0, terminateSimulation:
0, nominalsOfContinuousStatesChanged: 0, valuesOfContinuousStatesChanged: 0,
nextEventTimeDefined: 0, nextEventTime: 0.0), isDirtyValues: 1,
isNewEventIteration: 0)"
Traceback (most recent call last)
/home/jose/src/nimlang/fmu/ex02_moving_to_nim/lib/functions/others.nim(203)
fmi2Instantiate
/home/jose/.choosenim/toolchains/nim-1.6.10/lib/system/assign.nim(143)
genericAssign
/home/jose/.choosenim/toolchains/nim-1.6.10/lib/system/assign.nim(132)
genericAssignAux
/home/jose/.choosenim/toolchains/nim-1.6.10/lib/system/assign.nim(25)
genericAssignAux
/home/jose/.choosenim/toolchains/nim-1.6.10/lib/system/assign.nim(22)
genericAssignAux
/home/jose/.choosenim/toolchains/nim-1.6.10/lib/system/assign.nim(140)
genericAssignAux
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
./build.sh: line 8: 569360 Segmentation fault (core dumped)
./fmuCheck.linux64 inc.fmu
Run
The file `others.nim` simply instantiate an object:
{.push exportc:"$1",dynlib,cdecl.}
proc fmi2Instantiate*( instanceName: fmi2String;
fmuType: fmi2Type;
fmuGUID: fmi2String;
fmuResourceLocation: fmi2String;
functions: fmi2CallbackFunctions;
visible: fmi2Boolean;
loggingOn: fmi2Boolean): ModelInstance =
....
var comp:ModelInstance
comp.time = 0
comp.instanceName = instanceName
...
echo repr $comp
return comp #<--- THIS IS THE LINE FAILING
Run
Any clue about in which direction I should look-at?