Skip to content

[libs][iOS] AdvSimdEncode hits PlatformNotSupportedException #96828

@mdh1418

Description

@mdh1418

Description

After #95513 was merged, some tests that eventually invoke EncodeToUtf8 such as

public static void HeapSort_Heapify_String(string[] elements)
began failing with PlatformNotSupportedException on iOS/tvOS arm64 lanes.

Test collection for System.Collections.Tests.PriorityQueue_PropertyTests
Test name: System.Collections.Tests.PriorityQueue_PropertyTests.HeapSort_Heapify_String
Exception messages: System.PlatformNotSupportedException : 
Exception stack traces:    at System.Runtime.Intrinsics.Arm.AdvSimd.Arm64.LoadVector128x3AndUnzip(Byte* address)
at System.Buffers.Text.Base64.EncodeToUtf8(ReadOnlySpan`1 bytes, Span`1 utf8, Int32& bytesConsumed, Int32& bytesWritten, Boolean isFinalBlock)
at System.Convert.ToBase64CharsLargeNoLineBreaks(ReadOnlySpan`1 bytes, Span`1 chars, Int32 charLengthRequired)
at System.Convert.ToBase64String(ReadOnlySpan`1 bytes, Base64FormattingOptions options)
at System.Convert.ToBase64String(Byte[] inArray)
at System.Collections.Tests.PriorityQueue_PropertyTests.GenString(Random random)
at System.Collections.Tests.PriorityQueue_PropertyTests.GenArray[String](Func`2 genElement, Random random)
at System.Collections.Tests.PriorityQueue_PropertyTests.<>c.<GetRandomStringArrays>b__16_0(Random random)
at System.Collections.Tests.PriorityQueue_PropertyTests.<GenerateMemberData>d__18`1[[System.String[], System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
at System.Linq.Enumerable.SelectEnumerableIterator`2[[System.Object, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Object[], System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()

It looks like LoadVector128x3AndUnzip is possibly the culprit, as #84510 doesn't seem to account for mono.

Reproduction Steps

On OSX with an iOS device

./build.sh -s mono+libs -os ios -arch arm64 -c debug
./dotnet.sh build src/libraries/System.Collections/tests/System.Collections.Tests.csproj /t:Test /p:TargetOS=ios /p:TargetArchitecture=arm64 /p:Configuration=Debug /p:DevTeamProvisioning=<dev team provisioning ID> /p:XunitMethodName=System.Collections.Tests.PriorityQueue_PropertyTests.HeapSort_Heapify_String /p:MonoEnableLLVM=true /p:RunAOTCompilation=true

Expected behavior

Test doesn't fail with PlatformNotSupportedException

Actual behavior

Various tests eventually that end up calling AdvSimd.Arm64.LoadVector128x3AndUnzip on iOS/tvOS fail with PlatformNotSupportedException

Regression?

Yes

Known Workarounds

No-op AdvSimdEncode on mono

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions