Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Use System.Numerics.IEqualityOperators.op_Equality in SpanHelper.T.cs.
Workaround crash hit by #74179
making sure we avoid hitting codepath emitting this null pointer checks.
The full fix includes codegen fixes as well, but will be performed
in separate PR. There are still locations in SpanHelper.T.cs that uses
Equal virtual call on value types that could be managed pointers to
value types, but that code has remained the same for the last
4 years to 15 months and have not hit this issue in the past.
  • Loading branch information
lateralusX authored and github-actions committed Aug 29, 2022
commit 77d68a916293698fd8e381c796859a43335d1a33
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ private static int IndexOfValueType<TValue, TNegator>(ref TValue searchSpace, TV
{
length -= 1;

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

offset += 1;
}
Expand Down Expand Up @@ -2145,7 +2145,7 @@ private static int LastIndexOfValueType<TValue, TNegator>(ref TValue searchSpace
{
length -= 1;

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

offset -= 1;
}
Expand Down