-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
gh-136006: fix Py_NAN expansion on Solaris systems
#136575
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
2fbf141 to
85cffe2
Compare
No, I don't have access to Solaris. |
|
@kulikjak I think you're the Solaris expert here but could you confirm that this is the correct way to do it on Solaris? |
|
Uh, sorry - I missed this whole issue. Let me go through it. What I can say right now is that I am not seeing this issue on our side, but we are not building Python 3 on Solaris 10, so it wouldn't surprise me if there were some build issues. And also, there is a Solaris buildbot worker. I don't have a permission to start it, but you probably can ( |
|
!buildbot Solaris |
|
🤖 New build scheduled with the buildbot fleet by @picnixz for commit 85cffe2 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F136575%2Fmerge The command will test the builders whose names match following regular expression: The builders matched are:
|
|
So I tested the following on both the latest Solaris 10 (with gcc 7) and 11.4 (gcc 14): #include <stdio.h>
#include <math.h>
#define Py_NAN_A ((double)__builtin_nanf(""))
#define Py_NAN_B ((double)NAN)
int main(int argc, char const *argv[]) {
printf("%f\n", Py_NAN_A - 0.0);
printf("%f\n", Py_NAN_B - 0.0);
}and the result on both is the same. The code happily compiles, and both > /opt/gcc7/bin/gcc -E test.c
.....
# 7 "test.c"
int main(int argc, char const *argv[]) {
printf("%f\n", ((double)__builtin_nanf("")) - 0.0);
printf("%f\n", ((double)
# 9 "test.c" 3 4
(__builtin_nanf(""))
# 9 "test.c"
) - 0.0);
}So this PR is correct, but seems unnecessary in our case. I wonder if this changed during Solaris 10 lifetime, though that is IMHO unlikely. Maybe it's the even newer gcc (or some defines from Python itself that change the behavior)? |
|
Thank you! Can you check that |
|
Yes, I tested it and that works as expected on both 10 and 11 :) $ cat test.c
#include <stdio.h>
#include <math.h>
void main(int argc, char const *argv[]) {
fprintf(stderr, "%f\n", strtod("NAN", NULL));
}
$ /opt/gcc7/bin/gcc test.c
$ ./a.out
NaN |
|
And the buildbot seems as happy as currently possible. |
|
Thanks @picnixz for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
|
Thanks @picnixz for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14. |
|
Sorry, @picnixz, I could not cleanly backport this to |
|
GH-138733 is a backport of this pull request to the 3.14 branch. |
…thonGH-136575) On Solaris, `Py_NAN` may expand as a function address instead of a floating-point number. This amends commit 7a3b035. (cherry picked from commit d54b109) Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
|
GH-138734 is a backport of this pull request to the 3.13 branch. |
|
But was this change needed? Can we apply it only on Solaris 10? OpenIndiana also does not need this. @picnixz, you need to run the tests on the Solaris buildbot without this change to check that they were needed. |
Well, the issue is that it appears non-reproducible for Solaris 10 and 11 (the bot uses Solaris 11 but the bug seems to trigger only for Solaris 10 and not consistently), but the bug somehow exists (and probably due to gcc exact versions) as someone had it. It's documented in https://web.archive.org/web/20240806172752/https://www.gnu.org/software/gnulib/manual/html_node/math_002eh.html. Now, if it's possible to check for exact solaris version I would be happy but I don't know how to do it :( |
Python has the #if defined(_AIX) || (defined(__sun) && defined(__SVR4) && Py_SUNOS_VERSION <= 510)
/* issue #18259, sethostname is not declared in any useful header file on AIX
* the same is true for Solaris 10 */ |
|
I'll take care of this tomorrow then so that we only configure this for Solaris 10. |
|
If we cannot reproduce this, we cannot check that the new definition works on platforms where the issue is reproducible. So, it is either unneeded or untested. |
|
The original reporter mentioned that they are on Solaris 10, but I tried it on it and I cannot reproduce it. It might be the gcc version difference, or maybe the behavior changed during Solaris 10 lifetime (though this seems like quite a big change, so I don't think that's it)? I'd really like more info about that platform, because I cannot reproduce #136604 either. |
|
|
@TCH68k found out what the difference between our setup is (#136604 (comment)) - I have access to the latest Oracle Solaris 10 (U11), and they have the last Sun Solaris 10 (U8). And in case of It's possible that there are similar differences in this case as well. |
…tems (pythonGH-136575) (python#138734)" This reverts commit df34903 as discussed in python#138733 (comment)
…H-136575) (#138734)" (#139239) This reverts commit df34903 as discussed in #138733 (comment)
@vstinner do you have access to some Solaris machine to test this?