netgen icon indicating copy to clipboard operation
netgen copied to clipboard

Fix static initialization order for UserFormatRegister map

Open StefanBruens opened this issue 1 year ago • 1 comments

A std::map is in an invalid state when just zero-initialized, and needs to be initialized by its constructor. As this initilization may be done after the first call to Register, a crash will typically happen.

To fix this wrap all accesses to the map with a Meyers Singleton. Also remove the extra Array - most accesses are using the key, and the few format list iterations all sort the result afterwards anyway.

Fixes #201.

StefanBruens avatar Dec 19 '24 17:12 StefanBruens

There is also PR #125, which addresses the same problem elsewhere. Unfortunately, that has not been updated.

StefanBruens avatar Dec 19 '24 17:12 StefanBruens