Skip to content

New ConfigurationBindingGeneratorTests fail on s390x (endian issue?) #105311

Closed

Description

@uweigand

Since #104180 was merged, the following test cases are failing on s390x:

    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.Bind_T_BinderOptions [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.Collections [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.Bind_Instance_BinderOptions [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.BindConfiguration [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.Get_T_BinderOptions [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.Bind_Instance [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.Get_T [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.GetValue_T_Key_DefaultValue [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.Bind_CanParseTargetConfigType_FromMethodParam [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.Get_TypeOf [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.Bind_T [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.UnsupportedTypes [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.GetValue_TypeOf_Key [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.BindConfigurationWithConfigureActions [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.Configure_T_name_BinderOptions [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.GetValue_T_Key [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.MinimalGenerationIfNoBindableMembers [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.Bind_Key_Instance [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.Configure_T [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.DefaultConstructorParameters [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.GetValue_TypeOf_Key_DefaultValue [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.Get_TypeOf_BinderOptions [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.Primitives [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.Configure_T_name [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.Configure_T_BinderOptions [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.Get_PrimitivesOnly [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.GetValue [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.Get [FAIL]
    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.Bind [FAIL]

The symptom is in all cases of the type:

    Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.Bind [FAIL]
      Line 38 does not match.
      Expected Line:
              [InterceptsLocation(1, "/TzDbopkyui/vWzNJfmpq0IBAABzcmMtMC5jcw==")] // src-0.cs(12,14)
      Actual Line:
              [InterceptsLocation(1, "6sAEYxbTvjjW269lKa/ayUIBAABzcmMtMC5jcw==")] // src-0.cs(12,14)
      Stack Trace:
        /home/uweigand/runtime/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/GeneratorTests.Helpers.cs(175,0): at Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.VerifyAgainstBaselineUsingFile(String filename, String testSourceCode, ExtensionClassType extType, ExpectedDiagnostics expectedDiags)
        /home/uweigand/runtime/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/GeneratorTests.Baselines.cs(18,0): at Microsoft.Extensions.SourceGeneration.Configuration.Binder.Tests.ConfigurationBindingGeneratorTests.Bind()

It looks like the difference is in the InterceptableLocationData, which is provided by roslyn's Microsoft.CodeAnalysis.CSharp.InterceptableLocation1.Data. Specifically, the differences are in the checksum field, which is computed via the SourceText:GetContentHash() routine. From looking this this routine, it seems to simply re-interpret a string (char sequence) as byte array, see https://github.com/dotnet/roslyn/blob/aea9e82da403c397265f7fd0fefee5ebbb886179/src/Compilers/Core/Portable/Text/SourceText.cs#L645

hash.Append(MemoryMarshal.AsBytes(charBuffer.AsSpan(0, charsToCopy)));

This seems to imply that the hash value of the same source code will be different if computed on a big-endian vs. a little-endian machine (because the byte representation of each char will have its two bytes swapped).

Now my question would be: is the content hash supposed to be the same on big- and little-endian machines? If yes, that code in roslyn needs to be fixed. If no, then the ConfigurationBindingGeneratorTests will have to take that endian difference into account one way or the other.

CC @steveharter @tarekgh @directhex @steveisok
FIY @giritrivedi @saitama951 @omajid @tmds

Activity

  1. added
    untriaged
    on Jul 23, 2024
  2. dotnet-policy-service commented on Jul 23, 2024

    @dotnet-policy-service
    Contributor

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

  3. Vishwanatha-HD commented on Jul 23, 2024

    @Vishwanatha-HD

    Attaching the complete log file of the error which got reproduced..
    NET_runtime_Binder_Test_errors.txt

  4. tarekgh commented on Jul 23, 2024

    @tarekgh
    Member

    @steveharter is this something you can help looking at?

  5. added this to the 9.0.0 milestone on Jul 23, 2024
  6. added
    source-generator
    and removed
    untriaged
    on Jul 23, 2024
  7. self-assigned this
    on Jul 23, 2024
  8. steveharter commented on Jul 23, 2024

    @steveharter
    Contributor
  9. steveharter commented on Jul 23, 2024

    @steveharter
    Contributor

    This is similar to the question raised in #101079 (comment) where line endings can also vary based on platform.

  10. RikkiGibson commented on Jul 23, 2024

    @RikkiGibson
    Member

    I think we expect that if the file content is the same, these hashes should be the same.

    @CyrusNajmabadi is it expected that the result of GetContentHash() will vary depending on endianness?

  11. CyrusNajmabadi commented on Jul 23, 2024

    @CyrusNajmabadi
    Contributor

    It should be based entirely on the character content of the source files. It would be good if both were dumped out (literally every character and its integral value), and the two were compared.

    If they have the same characters, then GetContentHash should be the same.

    If they have different characters, then this is by design.

    Are we sure this isn't an issue around \r vs \r\n?

  12. uweigand commented on Jul 24, 2024

    @uweigand
    ContributorAuthor

    It should be based entirely on the character content of the source files. It would be good if both were dumped out (literally every character and its integral value), and the two were compared.

    If they have the same characters, then GetContentHash should be the same.

    I believe they have the same sequence of characters but not the same sequence of bytes, because each character has two bytes, and the order of those two bytes within a single character is endian-dependent. The current implementation of GetContentHash only returns the same value on the same sequence of bytes, not characters.

  13. added
    test-bug
    on Jul 24, 2024
  14. 8 remaining items

  15. CyrusNajmabadi commented on Jul 31, 2024

    @CyrusNajmabadi
    Contributor

    does it make sense at that time to normalize line endings so that files saved under Windows\Linux\OSX all have the same hash?

    Under no circumstances would we ever do this. Line ending is content and affects the runtime behavior of a program. Two programs with different line endings should not have the same hash as that would indicate they were identical.

  16. steveharter commented on Aug 7, 2024

    @steveharter
    Contributor

    @CyrusNajmabadi @RikkiGibson is there a tracking Roslyn issue?

    Do you expect this to be fixed in the v9.0 timeframe or should I move this to 10.0?

  17. RikkiGibson commented on Aug 7, 2024

    @RikkiGibson
    Member

    No, feel free to file an issue on Roslyn for the endianness behavior. I am guessing a fix in 9.0 is unlikely at this point.

  18. steveharter commented on Aug 8, 2024

    @steveharter
    Contributor

    Roslyn issue: dotnet/roslyn#74682

    I am guessing a fix in 9.0 is unlikely at this point.

    I am moving this to v10.

  19. modified the milestones: 9.0.0, 10.0.0 on Aug 8, 2024
  20. modified the milestones: 10.0.0, 11.0.0 on Feb 25, 2026
  21. assigned and unassigned on Mar 5, 2026
  22. locked and limited conversation to collaborators on Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

arch-s390xarea-Extensions-Configurationsource-generatortest-bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions