runtime: CI failure: System.Globalization.Tests.InvariantModeTests.TestLastIndexOf, object reference not set to an instance of an object

Affected tests:

  • System.Globalization.Tests.CompareInfoIndexOfTests.IndexOf_String (180x entries with 174x failures per run)
  • System.Globalization.Tests.InvariantModeTests.TestIndexOf (96x entries with 93x failures per run)
  • System.Globalization.Tests.InvariantModeTests.TestLastIndexOf (15x entire with 12x failures per run)

Total hits per run: 291x entries with 279x failures per run

Didn’t find any open issues reporting this. Please help determine if this needs a fix for RC1.

Found in this RC1 PR: #74045 Occurred in the runtime-extra-platforms run. Leg: Build windows x64 Release AllSubsets_Mono Job: https://dev.azure.com/dnceng/public/_build/results?buildId=1951942&view=logs&j=585f1246-0618-5d47-ff3e-08c83309e2d2&t=5e10daf8-cc46-5bd4-2ab7-d28eafd857b5&l=89

Callstacks:

Invariant.Tests.dll -xml testResults.xml -nologo -nocolor -notrait category=IgnoreForCI -notrait category=OuterLoop -notrait category=failing  
  Discovering: Invariant.Tests (method display = ClassAndMethod, method display options = None)
  Discovered:  Invariant.Tests (found 24 test cases)
  Starting:    Invariant.Tests (parallel test collections = on, max threads = 2)
    System.Globalization.Tests.InvariantModeTests.TestLastIndexOf(source: "Hi", value: "I", startIndex: 1, count: 2, options: None, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(2148,0): at System.SpanHelpers.LastIndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(217,0): at System.SpanHelpers.LastIndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs(1328,0): at System.Globalization.CompareInfo.LastIndexOf(ReadOnlySpan`1 source, ReadOnlySpan`1 value, CompareOptions options)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(175,0): at System.MemoryExtensions.LastIndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(958,0): at System.Globalization.Tests.InvariantModeTests.<TestLastIndexOf>g__TestCore|27_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(919,0): at System.Globalization.Tests.InvariantModeTests.TestLastIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestLastIndexOf(source: "Hi", value: "I", startIndex: 1, count: 2, options: None, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(2148,0): at System.SpanHelpers.LastIndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(217,0): at System.SpanHelpers.LastIndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs(1328,0): at System.Globalization.CompareInfo.LastIndexOf(ReadOnlySpan`1 source, ReadOnlySpan`1 value, CompareOptions options)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(175,0): at System.MemoryExtensions.LastIndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(958,0): at System.Globalization.Tests.InvariantModeTests.<TestLastIndexOf>g__TestCore|27_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(919,0): at System.Globalization.Tests.InvariantModeTests.TestLastIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestLastIndexOf(source: "Hi", value: "I", startIndex: 1, count: 2, options: None, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(2148,0): at System.SpanHelpers.LastIndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(217,0): at System.SpanHelpers.LastIndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs(1328,0): at System.Globalization.CompareInfo.LastIndexOf(ReadOnlySpan`1 source, ReadOnlySpan`1 value, CompareOptions options)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(175,0): at System.MemoryExtensions.LastIndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(958,0): at System.Globalization.Tests.InvariantModeTests.<TestLastIndexOf>g__TestCore|27_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(919,0): at System.Globalization.Tests.InvariantModeTests.TestLastIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestLastIndexOf(source: "Hi", value: "I", startIndex: 1, count: 2, options: None, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(2148,0): at System.SpanHelpers.LastIndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(217,0): at System.SpanHelpers.LastIndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs(1328,0): at System.Globalization.CompareInfo.LastIndexOf(ReadOnlySpan`1 source, ReadOnlySpan`1 value, CompareOptions options)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(175,0): at System.MemoryExtensions.LastIndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(958,0): at System.Globalization.Tests.InvariantModeTests.<TestLastIndexOf>g__TestCore|27_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(919,0): at System.Globalization.Tests.InvariantModeTests.TestLastIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "Hi", value: "I", startIndex: 0, count: 2, options: None, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs(954,0): at System.Globalization.CompareInfo.IndexOf(ReadOnlySpan`1 source, ReadOnlySpan`1 value, CompareOptions options)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(140,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "Hi", value: "I", startIndex: 0, count: 2, options: None, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs(954,0): at System.Globalization.CompareInfo.IndexOf(ReadOnlySpan`1 source, ReadOnlySpan`1 value, CompareOptions options)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(140,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "Hi", value: "I", startIndex: 0, count: 2, options: None, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs(954,0): at System.Globalization.CompareInfo.IndexOf(ReadOnlySpan`1 source, ReadOnlySpan`1 value, CompareOptions options)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(140,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "Hi", value: "I", startIndex: 0, count: 2, options: None, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs(954,0): at System.Globalization.CompareInfo.IndexOf(ReadOnlySpan`1 source, ReadOnlySpan`1 value, CompareOptions options)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(140,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "a", value: "a", startIndex: 0, count: 1, options: Ordinal, result: 0) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "a", value: "A", startIndex: 0, count: 1, options: Ordinal, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "a", value: "1", startIndex: 0, count: 1, options: Ordinal, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "1", value: "1", startIndex: 0, count: 1, options: Ordinal, result: 0) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "1", value: "!", startIndex: 0, count: 1, options: Ordinal, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "a", value: "-", startIndex: 0, count: 1, options: Ordinal, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "-", value: "-", startIndex: 0, count: 1, options: Ordinal, result: 0) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "-", value: "!", startIndex: 0, count: 1, options: Ordinal, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "!", value: "!", startIndex: 0, count: 1, options: Ordinal, result: 0) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "A", value: "?", startIndex: 0, count: 1, options: Ordinal, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "?", value: "A", startIndex: 0, count: 1, options: Ordinal, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "I", value: "i", startIndex: 0, count: 1, options: Ordinal, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "I", value: "I", startIndex: 0, count: 1, options: Ordinal, result: 0) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "i", value: "I", startIndex: 0, count: 1, options: Ordinal, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "i", value: "i", startIndex: 0, count: 1, options: Ordinal, result: 0) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "I", value: "I", startIndex: 0, count: 1, options: Ordinal, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "I", value: "I", startIndex: 0, count: 1, options: Ordinal, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "i", value: "I", startIndex: 0, count: 1, options: Ordinal, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "I", value: "i", startIndex: 0, count: 1, options: Ordinal, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "I", value: "i", startIndex: 0, count: 1, options: Ordinal, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "\0131", value: "I", startIndex: 0, count: 1, options: Ordinal, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "i", value: "i", startIndex: 0, count: 1, options: Ordinal, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "i", value: "i", startIndex: 0, count: 1, options: Ordinal, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "I", value: "I", startIndex: 0, count: 1, options: Ordinal, result: 0) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "i", value: "i", startIndex: 0, count: 1, options: Ordinal, result: 0) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "I", value: "i", startIndex: 0, count: 1, options: Ordinal, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
    System.Globalization.Tests.InvariantModeTests.TestIndexOf(source: "i", value: "I", startIndex: 0, count: 1, options: Ordinal, result: -1) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs(1501,0): at System.SpanHelpers.IndexOfValueType[Int16,DontNegate`1](Int16& searchSpace, Int16 value, Int32 length)
        /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs(26,0): at System.SpanHelpers.IndexOf(Char& searchSpace, Int32 searchSpaceLength, Char& value, Int32 valueLength)
        /_/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.Globalization.cs(133,0): at System.MemoryExtensions.IndexOf(ReadOnlySpan`1 span, ReadOnlySpan`1 value, StringComparison comparisonType)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(898,0): at System.Globalization.Tests.InvariantModeTests.<TestIndexOf>g__TestCore|26_0(CompareInfo compareInfo, String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/libraries/System.Globalization/tests/Invariant/InvariantMode.cs(872,0): at System.Globalization.Tests.InvariantModeTests.TestIndexOf(String source, String value, Int32 startIndex, Int32 count, CompareOptions options, Int32 result)
        /_/src/mono/System.Private.CoreLib/src/System/Reflection/MethodInvoker.Mono.cs(33,0): at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
  Finished:    Invariant.Tests
=== TEST EXECUTION SUMMARY ===
   Invariant.Tests  Total: 369, Errors: 0, Failed: 35, Skipped: 0, Time: 0.744s

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (20 by maintainers)

Commits related to this issue

Most upvoted comments

cc: @GrabYourPitchforks (a win for BoundedMemory)

split the fix into a PR fixing the SpanHelpers.T.cs and one handling the codegen fixes

I’d prefer that so we can backport to 7.0 and reenable the tests.

Sounds good, I will add a PR that fix SpanHelpers.T.cs and re-enable the test that could be backported and a separate PR with the codegen fix that we can start out in main and then decide if we should backport or not.

split the fix into a PR fixing the SpanHelpers.T.cs and one handling the codegen fixes

I’d prefer that so we can backport to 7.0 and reenable the tests.

We should still fix the null check implementation, but optimizing the equal check also makes sense. It is implemented like that in a couple of places in SpanHelpers.T.cs that would suffer similar issues.

And most likely using the equality check would introduce lower risk compared to fixing the codegen? Which would make it easier to backport the fix to 7?

Indeed, but I think we might need the codegen fix as well since that could potentially hit us in other scenarios, virtual call on managed pointers, pointing to something < 4 bytes. It will also trigger unaligned reads, so there is a small hidden perf cost. Having that said, the codegen issue has been around for sometime and just recently exposed by changes to SpanHelpers.T.cs and use of BoundedMemory testing it, so it could be argueed to split the fix into a PR fixing the SpanHelpers.T.cs and one handling the codegen fixes. I can work on both since I’m in the process working on the codegen fixes at the moment.

“Managed pointers cannot be null, and they shall be reported to the garbage collector even if they do not point to managed memory”

“Managed pointers cannot be null” sentence is removed in https://github.com/dotnet/runtime/blob/main/docs/design/specs/Ecma-335-Augments.md

The crash happens in Mono when we execute this code, part of LastIndexOfValueType:

while (length > 0)
{
    length -= 1;

    if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset).Equals(value))) return (int)offset;

    offset -= 1;
}

Unsafe.Add returns an Int16& that will have Equals called on it. The call to Equals in this case will be done using callvirt, meaning that Mono will inject a “this null check”. The actual virtual call will then be devirtualized and inline by Mono, but the “this null check” is kept. Problem with “this null check” on x86, x64 backends is that they are implemented using cmp DWORD PTR [reg], 0 on platforms using implicit null checks (supporting async exception handlers) and in the case of managed pointers, that can be interior pointers, that null check could actually read outside allocated memory, since its always reading 4 bytes (it can also cause unaligned reads). On arm/arm64, the check is implemented using byte loads, meaning that it won’t trigger the same issue.

Looking into a fix where we change the implementation of null checks on platforms reading more than 1 byte, into an implementation that only read 1 byte, making sure we won’t read passed allocated buffer. On x64 we would then change it from:

cmp DWORD PTR [reg], 0

to:

cmp BYTE PTR [reg], reg

Switching to a reg instead of imm 0 on x64 will also reduce the encoded instruction with 1 byte (already done this way on x86).

LLVM also reads to much in the null check:

LLVMBuildLoad2 (builder, IntPtrType (), convert (ctx, lhs, pointer_type (IntPtrType ())), "");

will look into changing that into:

LLVMBuildLoad2 (builder, LLVMInt8Type (), convert (ctx, lhs, pointer_type (LLVMInt8Type ())), "");

Another thing worth pointing out, most of the code in LastIndexOfValueType doesn’t do the equal using callvirt, but instead does:

Unsafe.Add(ref searchSpace, offset) == value

that will trigger a call to op_Equality, and since its not a virtual call, runtime won’t emit a “this null check”, reducing number of instructions. Don’t see why we shouldn’t change:

if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset).Equals(value))) return (int)offset;

to:

if (TNegator.NegateIfNeeded(Unsafe.Add(ref searchSpace, offset) == value)) return (int)offset;

and eliminate the complete virtual call. We should still fix the null check implementation, but optimizing the equal check also makes sense. It is implemented like that in a couple of places in SpanHelpers.T.cs that would suffer similar issues.

One last comment/note around managed pointers, reading up on ECMA - 335 it says:

Managed pointers cannot be null, and they shall be reported to the garbage collector even if they do not point to managed memory”

@lambdageek, when we discussed that yesterday, you mentioned that they actual can be null meaning that we should emit the needed null check as we currently do, but looking at the spec, maybe that is too defensive and we waste instructions? Thoughts?

I have fix for x86/x64 done, needs to run more on the LLVM fix before submitting a PR.

I take a look and see what needs to be done, it’s probably related to x64 Windows value type ABI implementation on Mono.