Skip to content

Test failures in hashing on Browser #69806

Closed

Description

@bartonjs

https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-69668-merge-9dd411182c95433daa/WasmTestOnBrowser-System.Security.Cryptography.Tests/1/console.fdc2faf5.log?helixlogtype=result

[08:20:42] info: Starting:    System.Security.Cryptography.Tests.dll
[08:20:46] fail: [FAIL] System.Security.Cryptography.Tests.Sha1ManagedTests.Sha1_Rfc3174_3_Async
[08:20:46] info: Showing first 10 differences
[08:20:46] info:   Position 0: Expected: 52, Actual: 217
[08:20:46] info:   Position 1: Expected: 170, Actual: 73
[08:20:46] info:   Position 2: Expected: 151, Actual: 231
[08:20:46] info:   Position 3: Expected: 60, Actual: 108
[08:20:46] info:   Position 4: Expected: 212, Actual: 115
[08:20:46] info:   Position 5: Expected: 196, Actual: 7
[08:20:46] info:   Position 6: Expected: 218, Actual: 236
[08:20:46] info:   Position 7: Expected: 164, Actual: 195
[08:20:46] info:   Position 8: Expected: 246, Actual: 62
[08:20:46] info:   Position 9: Expected: 30, Actual: 42
[08:20:46] info: Total number of differences: 20 out of 20
[08:20:46] info:    at System.AssertExtensions.SequenceEqual[Byte](ReadOnlySpan`1 expected, ReadOnlySpan`1 actual)
[08:20:46] info:    at System.AssertExtensions.SequenceEqual[Byte](Span`1 expected, Span`1 actual)
[08:20:46] info:    at System.Security.Cryptography.Tests.HashAlgorithmTestDriver.VerifyOneShotStreamAsync(Stream input, String output)
[08:20:46] info:    at System.Security.Cryptography.Tests.HashAlgorithmTestDriver.VerifyRepeatingAsync(String input, Int32 repeatCount, String output)
[08:20:46] info:    at System.Security.Cryptography.Tests.Sha1Tests.Sha1_Rfc3174_3_Async()
[08:20:46] info: --- End of stack trace from previous location ---
[08:21:07] info: Finished:    System.Security.Cryptography.Tests.dll
[08:21:07] info: 
[08:21:07] info: === TEST EXECUTION SUMMARY ===
[08:21:07] info: Total: 1163, Errors: 0, Failed: 1, Skipped: 1, Time: 24.820985s

https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-69786-merge-4202b33d23d54c99bd/WasmTestOnBrowser-System.Security.Cryptography.Tests/1/console.99f7714c.log?helixlogtype=result

[10:47:51] info: Starting:    System.Security.Cryptography.Tests.dll
[10:47:55] fail: [FAIL] System.Security.Cryptography.Tests.Sha256Tests.Sha256_Fips180_3
[10:47:55] info: Assert.Equal() Failure
[10:47:55] info:            ↓ (pos 0)
[10:47:55] info: Expected: [205, 199, 110, 92, 153, ...]
[10:47:55] info: Actual:   [156, 156, 59, 215, 224, ...]
[10:47:55] info:            ↑ (pos 0)
[10:47:55] info:    at System.Security.Cryptography.Tests.HashAlgorithmTestDriver.VerifyOneShotAllocatingStream(Stream input, String output)
[10:47:55] info:    at System.Security.Cryptography.Tests.HashAlgorithmTestDriver.VerifyRepeating(String input, Int32 repeatCount, String output)
[10:47:55] info:    at System.Security.Cryptography.Tests.Sha256Tests.Sha256_Fips180_3()
[10:47:55] info:    at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
[10:48:00] fail: [out of order message from the browser]: http://127.0.0.1:35197/dotnet.js 2:70309 Uncaught
[11:02:46] fail: Application has finished with exit code TIMED_OUT but 0 was expected
XHarness exit code: 71 (GENERAL_FAILURE)
/datadisks/disk1/work/A6E90937/w/A157086B/e /datadisks/disk1/work/A6E90937/w/A157086B/e
----- end Wed May 25 11:02:46 UTC 2022 ----- exit code 71 ----------------------------------------------------------

Both of these tests are testing the hash of one million ASCII lowercase a characters.

Having run through hashes of {}, {'a'}, {'a', 'a'}, all the way up to 5 million, for both SHA-1 and SHA-2-256, I can't reproduce either of these error values.

It seems like, somehow, bad data got into the pipeline... it's not a case of too much, or too little.

Also noteworthy is that each of these failed in the allocating one-shots over streams (public static byte[] HashData(Stream), and the async variant), after successfully doing it via other methods.

Activity

  1. added this to the 7.0.0 milestone on May 25, 2022
  2. ericstj commented on May 25, 2022

    @ericstj
    Member

    @bartonjs were you testing in the exact same environment as the test? Ubuntu, amd64, WasmTestOnNodeJs?

  3. vcsjones commented on May 25, 2022

    @vcsjones
    Member

    Any chance it's concurrency related? Concurrent test execution?

  4. added
    arch-wasmWebAssembly architecture
    and removed on May 25, 2022
  5. lewing commented on May 25, 2022

    @lewing
    Member

    @radical can you also keep an eye on any failures in the hashing tests to make sure we know the status here

  6. bartonjs commented on May 26, 2022

    @bartonjs
    MemberAuthor

    were you testing in the exact same environment as the test? Ubuntu, amd64, WasmTestOnNodeJs?

    No. Windows/amd64/Console, as an attempt to reproduce the values reported as 'actual' by the failures. (Crack the hash... crypto mining for flyweights)

    private static void Main()
    {
        IncrementalHash hash = IncrementalHash.CreateHash(HashAlgorithmName.SHA1);
        byte[] buf = new byte[1024];
        buf.AsSpan().Fill((byte)'a');
    
        int count = 0;
        const int Target1 = 0;
    
        while (count < Target1)
        {
            int len = Math.Min(Target1 - count, buf.Length);
            hash.AppendData(buf.AsSpan(0, len));
            count += len;
        }
    
        const int Target2 = 5_000_000;
        //ReadOnlySpan<byte> matchSHA256 = stackalloc byte[] { 156, 156, 59 };//, 215, 224 };
        //ReadOnlySpan<byte> matchSHA1 = stackalloc byte[] { 217, 73, 231 };//, 108, 115, 7, 236, 194, 62, 42 };
        // This is the right answer, to test that it reports a hit at i=1_000_000
        ReadOnlySpan<byte> matchSHA1 = stackalloc byte[] { 52, 170, 151, 60, 212, 196, 218, 164, 246, 30 };
        ReadOnlySpan<byte> match = matchSHA1;
        ReadOnlySpan<byte> oneA = buf.AsSpan(0, 1);
        Span<byte> hashOut = stackalloc byte[128];
    
        for (int i = count; i < Target2; i++)
        {
            hash.TryGetCurrentHash(hashOut, out int written);
    
            if (hashOut.Slice(0, match.Length).SequenceEqual(match))
            {
                Console.WriteLine($"Partial hit at i={i}");
            }
    
            hash.AppendData(oneA);
        }
    }
  7. bartonjs commented on May 26, 2022

    @bartonjs
    MemberAuthor

    Any chance it's concurrency related? Concurrent test execution?

    I didn't think wasm had concurrency...

  8. radical commented on May 26, 2022

    @radical
    Member

    @bartonjs were you testing in the exact same environment as the test? Ubuntu, amd64, WasmTestOnNodeJs?

    The test is running on chrome, and not nodejs.

  9. buyaa-n commented on May 26, 2022

    @buyaa-n
    Contributor

    https://github.com/dotnet/runtime/pull/69815/checks?check_run_id=6615945253 probably related to this

    [19:57:03] info: Starting:    System.Security.Cryptography.Tests.dll
    [19:57:15] fail: [out of order message from the browser]: http://127.0.0.1:37699/dotnet.js 2:70388 Uncaught
    [20:11:56] fail: Application has finished with exit code TIMED_OUT but 0 was expected
    XHarness exit code: 71 (GENERAL_FAILURE)
    

    Log: https://helixre8s23ayyeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-69815-merge-5dc2e2518ad14b9dbc/WasmTestOnBrowser-System.Security.Cryptography.Tests/1/console.6a6c9876.log?helixlogtype=result

  10. radical commented on May 26, 2022

    @radical
    Member

    this is very odd:
    [19:57:15] fail: [out of order message from the browser]: http://127.0.0.1:37699/dotnet.js 2:70388 Uncaught

    • no other messages at all. And then the test times out after ~15mins.
    • It would be helpful to run tests with WasmXHarnessArgs=--no-headless, and check the js console.
  11. 2 remaining items

  12. maraf commented on May 31, 2022

    @maraf
    Member

    Another hit on today's rolling build #20220531.2.

    [09:03:34] info: Using random seed for test cases: 1600464845
    [09:03:34] info: Using random seed for collections: 1600464845
    [09:03:34] info: Starting:    System.Security.Cryptography.Tests.dll
    [09:03:57] fail: [FAIL] System.Security.Cryptography.Tests.Sha512ManagedTests.Sha512_Fips180_3_Async
    [09:03:57] info: Showing first 10 differences
    [09:03:57] info:   Position 0: Expected: 231, Actual: 28
    [09:03:57] info:   Position 1: Expected: 24, Actual: 40
    [09:03:57] info:   Position 2: Expected: 72, Actual: 111
    [09:03:57] info:   Position 3: Expected: 61, Actual: 3
    [09:03:57] info:   Position 4: Expected: 12, Actual: 7
    [09:03:57] info:   Position 5: Expected: 231, Actual: 153
    [09:03:57] info:   Position 6: Expected: 105, Actual: 79
    [09:03:57] info:   Position 7: Expected: 100, Actual: 143
    [09:03:57] info:   Position 8: Expected: 78, Actual: 91
    [09:03:57] info:   Position 9: Expected: 46, Actual: 56
    [09:03:57] info: Total number of differences: 64 out of 64
    [09:03:57] info:    at System.AssertExtensions.SequenceEqual[Byte](ReadOnlySpan`1 expected, ReadOnlySpan`1 actual)
    [09:03:57] info:    at System.AssertExtensions.SequenceEqual[Byte](Span`1 expected, Span`1 actual)
    [09:03:57] info:    at System.Security.Cryptography.Tests.HashAlgorithmTestDriver.VerifyOneShotStreamAsync(Stream input, String output)
    [09:03:57] info:    at System.Security.Cryptography.Tests.HashAlgorithmTestDriver.VerifyRepeatingAsync(String input, Int32 repeatCount, String output)
    [09:03:57] info:    at System.Security.Cryptography.Tests.Sha512Tests.Sha512_Fips180_3_Async()
    [09:03:57] info: --- End of stack trace from previous location ---
    [09:04:02] info: Finished:    System.Security.Cryptography.Tests.dll
    [09:04:02] info: 
    [09:04:02] info: === TEST EXECUTION SUMMARY ===
    [09:04:02] info: Total: 1159, Errors: 0, Failed: 1, Skipped: 1, Time: 27.912s
    
  13. added
    blocking-clean-ciBlocking PR or rolling runs of 'runtime' or 'runtime-extra-platforms'
    on Jun 1, 2022
  14. agocke commented on Jun 1, 2022

    @agocke
    Member

    This is failing regularly in CI -- can we add test retries or disable the test, assuming there's no fix at the moment?

  15. assigned and unassigned on Jun 1, 2022
  16. buyaa-n commented on Jun 2, 2022

    @buyaa-n
    Contributor

    Another failure on: https://github.com/dotnet/runtime/pull/70065/checks?check_run_id=6699909171

    [23:38:03] fail: [FAIL] System.Security.Cryptography.Tests.Sha256ManagedTests.Sha256_Fips180_3_Async
    [23:38:03] info: Showing first 10 differences
    [23:38:03] info:   Position 0: Expected: 205, Actual: 156
    [23:38:03] info:   Position 1: Expected: 199, Actual: 224
    [23:38:03] info:   Position 2: Expected: 110, Actual: 196
    [23:38:03] info:   Position 3: Expected: 92, Actual: 198
    [23:38:03] info:   Position 4: Expected: 153, Actual: 35
    [23:38:03] info:   Position 5: Expected: 20, Actual: 7
    [23:38:03] info:   Position 6: Expected: 251, Actual: 248
    [23:38:03] info:   Position 7: Expected: 146, Actual: 83
    [23:38:03] info:   Position 8: Expected: 129, Actual: 99
    [23:38:03] info:   Position 9: Expected: 161, Actual: 38
    [23:38:03] info: Total number of differences: 32 out of 32
    [23:38:03] info:    at System.AssertExtensions.SequenceEqual[Byte](ReadOnlySpan`1 expected, ReadOnlySpan`1 actual)
    [23:38:03] info:    at System.AssertExtensions.SequenceEqual[Byte](Span`1 expected, Span`1 actual)
    [23:38:03] info:    at System.Security.Cryptography.Tests.HashAlgorithmTestDriver.VerifyOneShotStreamAsync(Stream input, String output)
    [23:38:03] info:    at System.Security.Cryptography.Tests.HashAlgorithmTestDriver.VerifyRepeatingAsync(String input, Int32 repeatCount, String output)
    [23:38:03] info:    at System.Security.Cryptography.Tests.Sha256Tests.Sha256_Fips180_3_Async()
    [23:38:03] info: --- End of stack trace from previous location ---
    

    https://helixre107v0xdeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-70065-merge-98fea3a4daa64d8eac/WasmTestOnBrowser-System.Security.Cryptography.Tests/1/console.a690da3d.log?helixlogtype=result

  17. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Jun 2, 2022
  18. added a commit that references this issue on Jun 3, 2022
    dbb2532
  19. maraf commented on Jun 7, 2022

    @maraf
    Member

    Another hit on #20220606.48

    [20:56:27] fail: [FAIL] System.Security.Cryptography.Tests.Sha1ManagedTests.Sha1_Rfc3174_3
    [20:56:27] info: Assert.Equal() Failure
    [20:56:27] info:            ↓ (pos 0)
    [20:56:27] info: Expected: [52, 170, 151, 60, 212, ...]
    [20:56:27] info: Actual:   [183, 139, 13, 2, 30, ...]
    [20:56:27] info:            ↑ (pos 0)
    [20:56:27] info:    at System.Security.Cryptography.Tests.HashAlgorithmTestDriver.VerifyOneShotAllocatingStream(Stream input, String output)
    [20:56:27] info:    at System.Security.Cryptography.Tests.HashAlgorithmTestDriver.VerifyRepeating(String input, Int32 repeatCount, String output)
    [20:56:27] info:    at System.Security.Cryptography.Tests.Sha1Tests.Sha1_Rfc3174_3()
    [20:56:27] info:    at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    
  20. added a commit that references this issue on Jun 7, 2022
    8d34e0a
  21. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Jun 7, 2022
  22. ghost locked as resolved and limited conversation to collaborators on Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

arch-wasmWebAssembly architecturearea-System.Securityblocking-clean-ciBlocking PR or rolling runs of 'runtime' or 'runtime-extra-platforms'

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions