-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Make C-lib math functions introspection more robust #35325
Conversation
Tagging subscribers to this area: @ViktorHofer |
@janvorli, I have also fixed two CMake CMake Warning (dev) in src/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt:
A logical block opening on the line
/usbkey/home/root/runtime/src/coreclr/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt:25 (if)
closes on the line
/usbkey/home/root/runtime/src/coreclr/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt:27 (endif)
with mis-matching arguments. |
@maryamariyan bad label :) |
@danmosemsft I updated the bot labeler earlier today to undo applying labels based on the second fallback model. |
Which tests caught this? We should have coverage of all the IEEE required inputs/outputs on both the managed and native side. For example: |
@maryamariyan oh ok. It's actually pretty reasonable from a bot POV. |
@tannergooding, currently:
|
From cppreference - atan2:
this case is violating on Illumos, which palsuite exercises. The incorrect result is produced, when compilers (clang, or gcc) do not make use of use of the builtin atan2, and instead calls the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
|
||
result = atan2(0.0, -0.0); | ||
result = atan2(y, -x); | ||
if (fabs(pi - result) > 0.0000001) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This (and others checking against a "close enough" result) should ideally get cleaned up as well. IEEE floating-point is deterministic, if nothing else, and so the result should be exactly Math.PI
(which is the nearest representation of "true pi").
I'll log a bug and see about following up after this gets merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logged #35341
On Solaris-like operating systems (such as SmartOS 2020 and OpenIndiana hipster), when built without optimization enabled (e.g.
-O2
); if the hard-coded value of-0.0
is used forx
argument ofatan2(3)
, it produces value of PI correctly, when y is0.0
.However, it produces an incorrect result if the value of
x
is soft-coded and a unary operator is used, like-x
.The following program demonstrates the issue:
gives us:
hard-coded 3.14159 vs. soft-coded 0
, with -O2, it produces the correct value (of PI for both hard- and soft- coded cases).With clang-9 on OI, it gives us:
hard-coded 0 vs. soft-coded 0
with and without -O2.This is most likely the bug in
libm
, which I have reported in upstream channel.We already have a fallback implementation under
HAVE_COMPATIBLE_ATAN2
.This PR makes the test case more robust, so it fails on Solaris.