admb-project / admb

AD Model Builder
http://admb-project.org
Other
64 stars 19 forks source link

Segmentation Errors using mingw-w64 versions 8.x and 9.x in dev branch #205

Closed johnoel closed 3 years ago

johnoel commented 3 years ago

The following line from src\linad99\adglobl.cpp fails with stack errors during testing for only the mingw-w64 compiler versions 8 and 9, but works for version 7.

thread_local gradient_structure* gradient_structure::_instance = nullptr;
johnoel commented 3 years ago

Found a workaround. For this compiler, the functions that uses the static thread_local instance must be in the same source file.

johnoel commented 3 years ago

It turns out the root of the problem was not the compiler, but an issue with gradient_structure destructor. Since gradient_structure::_instance is static and global and changes for each thread instance, it must be reset to the correct instance to properly clean the members of the class.

Resolved in commit https://github.com/admb-project/admb/commit/c42143a50f506021f6fe4795780f498a1c789cb4