Skip to content

Loading float numbers from external data CSV file fails. #534

@malinb73

Description

@malinb73

--- Context ---
Built fmusim for Windows:
Platform: x86_64-windows
CMake Generator: Visual Studio 16 2019
Build type: Debug

Git commit checked:
Revision: 6d3a981
Author: Torsten Sommer torsten.sommer@3ds.com
Date: 7/5/2024 11:19:21 AM
Message: Fix variable index in fmi3{Get|Set}Binary() (#531)

--- Description ---
The error happens when importing external data from a CSV file and amongst other different inputs there are also inputs having float types.

Example:
time,s8_in,s16_in,array1D_in,float32_in
0,1,2,3 4 5,12.34

The error happens randomly.
The error message is: "Failed to reallocate memory."
The error occurs in fmusim/FMIStaticInput.c in function:
FMIStatus FMIApplyInput(FMIInstance* instance, const FMIStaticInput* input, double time, bool discrete, bool continuous, bool afterEvent)
at line 276:
CALL(FMIRealloc((void**)&input->buffer, requiredBufferSize));
The reason is requiredBufferSize variable has sometimes a very huge value due to some wrong memory read which is based on row variable.
This row variable is calculated in the while block from lines 255, see: "while (row < input->nRows - 2) {...."
Changing the while condition to "while (row < input->nRows - 1)" seems to solve the problem.
Can you check please?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions