Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix static initialization order for UserFormatRegister map #202

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

StefanBruens
Copy link
Contributor

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.

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 NGSolve#201.
@StefanBruens
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using dlopen on libnglib.so crashes in std::map
1 participant