-
Notifications
You must be signed in to change notification settings - Fork 300
Fixes for "static initialization order fiasco" #1849
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
Conversation
Coverage test failed but this report seems OK: https://app.codecov.io/gh/symengine/symengine/compare/master...fiasco/changes |
This exercises the function `_sqrt_mod_tonelli_shanks` which was not previously tested.
Interesting! I am trying to understand some things:
|
thanks @cqc-alec ! re performance, I found I also looked at a few other benchmarks (but not all), only |
Thanks @lkeegan , yes passing the maps by reference is a good idea. I wonder why |
I tried making |
The test failure looks like a transient network issue. |
Here are the relative changes in timings for the
|
Thanks @cqc-alec for the explanation. I have been giving this some thought and I believe your solution is the best we can get for now. Ideally we would like to have static construction for the constants (i.e. |
Thanks again @cqc-alec |
When symengine is statically linked to a library, especially with link-time optimization, it can result in segfaults due to this issue: https://en.cppreference.com/w/cpp/language/siof
This PR tries to fix the instances I have found. It's possible I've missed some, but at least this is enough to avoid the issue in my use case involving pybind11 (527 valgrind errors from importing the python module reduced to 0).
Typically the fix is some form of the initialize-on-first-use idiom. For the constants, I introduced lambdas for this purpose to avoid having to add
()
to every reference to them in the code base.