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

Ensure floating-point types write the exponent/significand as little-endian #68331

Merged
merged 1 commit into from
Apr 22, 2022

Conversation

tannergooding
Copy link
Member

Discovered by @uweigand in #68141 (comment)

@ghost
Copy link

ghost commented Apr 21, 2022

Tagging subscribers to this area: @dotnet/area-system-numerics
See info in area-owners.md if you want to be subscribed.

Issue Details

Discovered by @uweigand in #68141 (comment)

Author: tannergooding
Assignees: tannergooding
Labels:

area-System.Numerics

Milestone: -

@tannergooding tannergooding merged commit 0e18cfd into dotnet:main Apr 22, 2022
Copy link
Contributor

@dakersnar dakersnar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Are there existing unit tests that catch this bug, at least before you fixed it?

@tannergooding
Copy link
Member Author

Yes. The problem is that we don't run any CI legs that cover big endian machines.

This was caught in the outer loop on some jobs running against an s390x on Mono.

@uweigand
Copy link
Contributor

The CI is running the full runtime test suite on s390x (this is the dotnet runtime using the Mono JIT):
https://dev.azure.com/dnceng/public/_build?definitionId=1052

But this is just running twice a day and not as part of the PR checks, so big endian breakages are usually not detected pre-commit unfortunately.

@uweigand
Copy link
Contributor

Thank, @tannergooding! This fixes the binary floating-point tests, but there's still a failure in a decimal floating-point test:

    System.Tests.DecimalTests_GenericMath.TryWriteSignificandLittleEndianTest [FAIL]
      Assert.Equal() Failure
                 ↓ (pos 0)
      Expected: [10, 0, 0, 0, 0, ...]
      Actual:   [0, 0, 0, 0, 0, ...]
                 ↑ (pos 0)
      Stack Trace:
        /_/src/libraries/System.Runtime/tests/System/DecimalTests.GenericMath.cs(1063,0): at System.Tests.DecimalTests_GenericMath.TryWriteSignificandLittleEndianTest()

Looks like this place also needs to be updated:

Unsafe.WriteUnaligned(ref address, _lo64);
Unsafe.WriteUnaligned(ref Unsafe.AddByteOffset(ref address, sizeof(ulong)), _hi32);

@ghost ghost locked as resolved and limited conversation to collaborators Sep 8, 2022
@tannergooding tannergooding deleted the generic-math-endian-fix branch November 11, 2022 15:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants