I tried to make an implementation fo the 2dtable which does not rely on having unique global variables. Since the implementation already uses malloc it does not seem to be a too big deal to use it for the global data table pointer array.
The issue is that which linux, windows, and mac (when compiled with clang on a mac) all seem to be able to load the global variables into an isolated space per loaded library. This is not the case for dylibs compiled with the cross-compiler. No matter what attributes or C tricks I try it always loads the library such that all globals are shared resulting in a runtime crash.
We discovered this for the linefollower after a slide change which meant that multiple FMUs had a 2dtable inside.
I tried to merge the changes into the template here. It would be good if we could change to implementation to avoid the issue. I simply have no idea on how to fix it otherwise.
The implementation relies on the fact that COE always unloads the FMUs in order. (it does not step at the same time that it calls terminate on different FMUs)
I tried to make an implementation fo the 2dtable which does not rely on having unique global variables. Since the implementation already uses malloc it does not seem to be a too big deal to use it for the global data table pointer array.
The issue is that which linux, windows, and mac (when compiled with clang on a mac) all seem to be able to load the global variables into an isolated space per loaded library. This is not the case for dylibs compiled with the cross-compiler. No matter what attributes or C tricks I try it always loads the library such that all globals are shared resulting in a runtime crash.
We discovered this for the linefollower after a slide change which meant that multiple FMUs had a 2dtable inside.
I tried to merge the changes into the template here. It would be good if we could change to implementation to avoid the issue. I simply have no idea on how to fix it otherwise.
The implementation relies on the fact that COE always unloads the FMUs in order. (it does not step at the same time that it calls terminate on different FMUs)