Skip to content

ReadOnlySpanTests.TestNoMatchValuesLargerLastIndexOfAny_Byte_ManyByte #118022

@pavelsavara

Description

@pavelsavara

Test generates random byte array and then assert aborts the runtime on assert.
This is debug build of browser/wasm interpreter. We don't run that combination on CI.
It happened on my devbox machine twice.

I suspect that IndexOfAnyAsciiSearcher.CanUseUniqueLowNibbleSearch doesn't have same meaning as Ascii.IsValid

  info: Starting:    System.Memory.Tests.dll
  warn: [MONO] Process terminated. Assertion failed.
  warn: [MONO] Ascii.IsValid(values) || (AdvSimd.IsSupported && TUniqueLowNibble.Value)
     at System.Diagnostics.DebugProvider.Fail(String message, String detailMessage) in D:\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\DebugProvider.cs:line 22
     at System.Diagnostics.Debug.Fail(String message, String detailMessage) in D:\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Debug.cs:line 134
     at System.Diagnostics.Debug.Assert(Boolean condition, String message, String detailMessage) in D:\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Debug.cs:line 98
     at System.Diagnostics.Debug.Assert(Boolean condition, String message) in D:\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Debug.cs:line 87
     at System.Buffers.AsciiByteSearchValues`1[[System.Buffers.SearchValues.TrueConst, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]..ctor(ReadOnlySpan`1 values) in D:\runtime\src\libraries\Syst
  em.Private.CoreLib\src\System\SearchValues\AsciiByteSearchValues.cs:line 23
     at System.Buffers.SearchValues.Create(ReadOnlySpan`1 values) in D:\runtime\src\libraries\System.Private.CoreLib\src\System\SearchValues\SearchValues.cs:line 50
     at System.SpanTests.SpanTests.LastIndexOfAny(Span`1 span, ReadOnlySpan`1 values) in D:\runtime\src\libraries\System.Memory\tests\Span\LastIndexOfAny.byte.cs:line 545
     at System.SpanTests.SpanTests.TestNoMatchValuesLargerLastIndexOfAny_Byte_ManyByte() in D:\runtime\src\libraries\System.Memory\tests\Span\LastIndexOfAny.byte.cs:line 465

// Depending on the hardware, UniqueLowNibble can be faster than even range or 2 values.
// It's currently consistently faster than 4/5 values on all tested platforms (Arm, Avx2, Avx512).
if (values.Length >= 4 && IndexOfAnyAsciiSearcher.CanUseUniqueLowNibbleSearch(values, maxInclusive))
{
return new AsciiByteSearchValues<TrueConst>(values);
}

public static bool CanUseUniqueLowNibbleSearch<T>(ReadOnlySpan<T> values, int maxInclusive)

Debug.Assert(Ascii.IsValid(values) || (AdvSimd.IsSupported && TUniqueLowNibble.Value));

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions