dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.91k stars 4.63k forks source link

CertificateRequest.Create(...) hangs on macOS 12.7.5 x64 #105438

Closed dtivel closed 3 days ago

dtivel commented 1 month ago

Description

I have some test code that recently started hanging in macOS x64 CI builds.

With dotnet test --blame-hang-timeout 60s I captured a hang dump with the following callstack:

00007000102EC648 00007ff80ff7a93a [InlinedCallFrame: 00007000102ec648] 

00007000102EC648 000000011c56d85e [InlinedCallFrame: 00007000102ec648] 

00007000102EC630 000000011C56D85E Interop+AppleCrypto.AppleCryptoNative_SecKeyCreateSignature(System.Security.Cryptography.Apple.SafeSecKeyRefHandle, Byte*, Int32, PAL_HashAlgorithm, PAL_SignatureAlgorithm, Microsoft.Win32.SafeHandles.SafeCFDataHandle ByRef, Microsoft.Win32.SafeHandles.SafeCFErrorHandle ByRef) [/_/src/libraries/System.Security.Cryptography/src/Microsoft.Interop.LibraryImportGenerator/Microsoft.Interop.LibraryImportGenerator/LibraryImports.g.cs @ 2769]

00007000102EC760 000000011C56DB27 Interop+AppleCrypto.NativeCreateSignature(System.Security.Cryptography.Apple.SafeSecKeyRefHandle, System.ReadOnlySpan`1<Byte>, PAL_HashAlgorithm, PAL_SignatureAlgorithm) [/_/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.SignVerify.cs @ 133]

00007000102EC7D0 000000011C56DC05 Interop+AppleCrypto.CreateSignature(System.Security.Cryptography.Apple.SafeSecKeyRefHandle, System.ReadOnlySpan`1<Byte>, PAL_HashAlgorithm, PAL_SignatureAlgorithm) [/_/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.SignVerify.cs @ 164]

00007000102EC800 000000011C5BCFD5 System.Security.Cryptography.RSAImplementation+RSASecurityTransforms.SignHash(Byte[], System.Security.Cryptography.HashAlgorithmName, System.Security.Cryptography.RSASignaturePadding) [/_/src/libraries/Common/src/System/Security/Cryptography/RSASecurityTransforms.cs @ 380]

00007000102EC860 000000011C5AB8AB System.Security.Cryptography.RSA.SignData(Byte[], Int32, Int32, System.Security.Cryptography.HashAlgorithmName, System.Security.Cryptography.RSASignaturePadding) [/_/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/RSA.cs @ 398]

00007000102EC8C0 000000011C5CFA80 System.Security.Cryptography.X509Certificates.CertificateRequest.Create(System.Security.Cryptography.X509Certificates.X500DistinguishedName, System.Security.Cryptography.X509Certificates.X509SignatureGenerator, System.DateTimeOffset, System.DateTimeOffset, System.ReadOnlySpan`1<Byte>) [/_/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/CertificateRequest.cs @ 885]

00007000102ED030 000000011C5CF02C System.Security.Cryptography.X509Certificates.CertificateRequest.Create(System.Security.Cryptography.X509Certificates.X509Certificate2, System.DateTimeOffset, System.DateTimeOffset, System.ReadOnlySpan`1<Byte>) [/_/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/CertificateRequest.cs @ 725]

00007000102ED0D0 000000011C5CED8D System.Security.Cryptography.X509Certificates.CertificateRequest.Create(System.Security.Cryptography.X509Certificates.X509Certificate2, System.DateTimeOffset, System.DateTimeOffset, Byte[]) [/_/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/CertificateRequest.cs @ 582]

00007000102ED130 000000011C50D422 System.Security.Cryptography.X509Certificates.Tests.Common.CertificateAuthority.CreateCertificate(System.String, System.Security.Cryptography.RSA, System.TimeSpan, System.Security.Cryptography.X509Certificates.X509ExtensionCollection, Boolean)

00007000102ED320 000000011C50CDE6 System.Security.Cryptography.X509Certificates.Tests.Common.CertificateAuthority.CreateSubordinateCA(System.String, System.Security.Cryptography.RSA, System.Nullable`1<Int32>)

00007000102ED3B0 000000011C4CC373 System.Security.Cryptography.X509Certificates.Tests.Common.CertificateAuthority.BuildPrivatePki(System.Security.Cryptography.X509Certificates.Tests.Common.PkiOptions, System.Security.Cryptography.X509Certificates.Tests.Common.RevocationResponder ByRef, System.Security.Cryptography.X509Certificates.Tests.Common.CertificateAuthority ByRef, System.Security.Cryptography.X509Certificates.Tests.Common.CertificateAuthority[] ByRef, System.Security.Cryptography.X509Certificates.X509Certificate2 ByRef, Int32, System.String, Boolean, Boolean, System.String, Int32, System.Security.Cryptography.X509Certificates.X509ExtensionCollection)

00007000102ED940 000000011C4C986A System.Security.Cryptography.X509Certificates.Tests.Common.CertificateAuthority.BuildPrivatePki(System.Security.Cryptography.X509Certificates.Tests.Common.PkiOptions, System.Security.Cryptography.X509Certificates.Tests.Common.RevocationResponder ByRef, System.Security.Cryptography.X509Certificates.Tests.Common.CertificateAuthority ByRef, System.Security.Cryptography.X509Certificates.Tests.Common.CertificateAuthority ByRef, System.Security.Cryptography.X509Certificates.X509Certificate2 ByRef, System.String, Boolean, Boolean, System.String, Int32, System.Security.Cryptography.X509Certificates.X509ExtensionCollection)

00007000102ED9D0 000000011C4C977D Repro.TestClass.TestMethod()

00007000102EDB78 000000010fc642c1 [HelperMethodFrame_PROTECTOBJ: 00007000102edb78] System.RuntimeMethodHandle.InvokeMethod(System.Object, Void**, System.Signature, Boolean)

00007000102EDE10 0000000118C34AA6 System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(System.Object, System.Reflection.BindingFlags) [/_/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.cs @ 57]

00007000102EDE50 000000011C4C96DC Xunit.Sdk.TestInvoker`1[[System.__Canon, System.Private.CoreLib]].CallTestMethod(System.Object) [/_/src/xunit.execution/Sdk/Frameworks/Runners/TestInvoker.cs @ 148]

00007000102EDE80 000000011C4C9386 Xunit.Sdk.TestInvoker`1+<>c__DisplayClass46_0+<<InvokeTestMethodAsync>b__1>d[[System.__Canon, System.Private.CoreLib]].MoveNext() [/_/src/xunit.execution/Sdk/Frameworks/Runners/TestInvoker.cs @ 250]

00007000102EE0E0 000000011C4C84D3 System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Xunit.Sdk.TestInvoker`1+<>c__DisplayClass46_0+<<InvokeTestMethodAsync>b__1>d[[System.__Canon, System.Private.CoreLib]], xunit.execution.dotnet]](<<InvokeTestMethodAsync>b__1>d<System.__Canon> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilderCore.cs @ 38]

00007000102EE170 000000011C4C8380 System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Xunit.Sdk.TestInvoker`1+<>c__DisplayClass46_0+<<InvokeTestMethodAsync>b__1>d[[System.__Canon, System.Private.CoreLib]], xunit.execution.dotnet]](<<InvokeTestMethodAsync>b__1>d<System.__Canon> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilder.cs @ 33]

00007000102EE1B0 000000011C4C82FB Xunit.Sdk.TestInvoker`1+<>c__DisplayClass46_0[[System.__Canon, System.Private.CoreLib]].<InvokeTestMethodAsync>b__1()

00007000102EE210 000000011C4C7FE3 Xunit.Sdk.ExecutionTimer+<AggregateAsync>d__4.MoveNext() [/_/src/xunit.execution/Sdk/Frameworks/ExecutionTimer.cs @ 48]

00007000102EE270 000000011C4C7E2B System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Xunit.Sdk.ExecutionTimer+<AggregateAsync>d__4, xunit.execution.dotnet]](<AggregateAsync>d__4 ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilderCore.cs @ 38]

00007000102EE2E0 000000011C4C7D0C System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Xunit.Sdk.ExecutionTimer+<AggregateAsync>d__4, xunit.execution.dotnet]](<AggregateAsync>d__4 ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilder.cs @ 33]

00007000102EE300 000000011C4C7CC5 Xunit.Sdk.ExecutionTimer.AggregateAsync(System.Func`1<System.Threading.Tasks.Task>)

00007000102EE350 000000011C4C7C48 Xunit.Sdk.TestInvoker`1+<>c__DisplayClass46_0[[System.__Canon, System.Private.CoreLib]].<InvokeTestMethodAsync>b__0() [/_/src/xunit.execution/Sdk/Frameworks/Runners/TestInvoker.cs @ 215]

00007000102EE3A0 000000011C4C7A0B Xunit.Sdk.ExceptionAggregator+<RunAsync>d__9.MoveNext() [/_/src/xunit.core/Sdk/ExceptionAggregator.cs @ 90]

00007000102EE410 000000011C4C77B5 System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Xunit.Sdk.ExceptionAggregator+<RunAsync>d__9, xunit.core]](<RunAsync>d__9 ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilderCore.cs @ 38]

00007000102EE480 000000011C4C771C System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Xunit.Sdk.ExceptionAggregator+<RunAsync>d__9, xunit.core]](<RunAsync>d__9 ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilder.cs @ 33]

00007000102EE4A0 000000011C4C76D6 Xunit.Sdk.ExceptionAggregator.RunAsync(System.Func`1<System.Threading.Tasks.Task>)

00007000102EE4F0 000000011C4C7185 Xunit.Sdk.TestInvoker`1+<InvokeTestMethodAsync>d__46[[System.__Canon, System.Private.CoreLib]].MoveNext() [/_/src/xunit.execution/Sdk/Frameworks/Runners/TestInvoker.cs @ 214]

00007000102EE5C0 000000011C4C6ACD System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Xunit.Sdk.TestInvoker`1+<InvokeTestMethodAsync>d__46[[System.__Canon, System.Private.CoreLib]], xunit.execution.dotnet]](<InvokeTestMethodAsync>d__46<System.__Canon> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilderCore.cs @ 38]

00007000102EE660 000000011C4C6930 System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.Decimal, System.Private.CoreLib]].Start[[Xunit.Sdk.TestInvoker`1+<InvokeTestMethodAsync>d__46[[System.__Canon, System.Private.CoreLib]], xunit.execution.dotnet]](<InvokeTestMethodAsync>d__46<System.__Canon> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs @ 35]

00007000102EE6A0 000000011C4C67CC Xunit.Sdk.TestInvoker`1[[System.__Canon, System.Private.CoreLib]].InvokeTestMethodAsync(System.Object)

00007000102EE710 000000011C4C5FAF Xunit.Sdk.XunitTestInvoker.InvokeTestMethodAsync(System.Object) [/_/src/xunit.execution/Sdk/Frameworks/Runners/XunitTestInvoker.cs @ 112]

00007000102EE760 000000011C4C3BDC Xunit.Sdk.TestInvoker`1+<<RunAsync>b__45_0>d[[System.__Canon, System.Private.CoreLib]].MoveNext() [/_/src/xunit.execution/Sdk/Frameworks/Runners/TestInvoker.cs @ 174]

00007000102EE870 000000011C4C371D System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Xunit.Sdk.TestInvoker`1+<<RunAsync>b__45_0>d[[System.__Canon, System.Private.CoreLib]], xunit.execution.dotnet]](<<RunAsync>b__45_0>d<System.__Canon> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilderCore.cs @ 38]

00007000102EE910 000000011C4C35A0 System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.Decimal, System.Private.CoreLib]].Start[[Xunit.Sdk.TestInvoker`1+<<RunAsync>b__45_0>d[[System.__Canon, System.Private.CoreLib]], xunit.execution.dotnet]](<<RunAsync>b__45_0>d<System.__Canon> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs @ 35]

00007000102EE950 000000011C4C34D0 Xunit.Sdk.TestInvoker`1[[System.__Canon, System.Private.CoreLib]].<RunAsync>b__45_0()

00007000102EE9C0 000000011C4C31A1 Xunit.Sdk.ExceptionAggregator+<RunAsync>d__10`1[[System.Decimal, System.Private.CoreLib]].MoveNext() [/_/src/xunit.core/Sdk/ExceptionAggregator.cs @ 107]

00007000102EEA50 000000011C4C2FD5 System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Xunit.Sdk.ExceptionAggregator+<RunAsync>d__10`1[[System.Decimal, System.Private.CoreLib]], xunit.core]](<RunAsync>d__10`1<System.Decimal> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilderCore.cs @ 38]

00007000102EEAC0 000000011C4C2F3C System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.Decimal, System.Private.CoreLib]].Start[[Xunit.Sdk.ExceptionAggregator+<RunAsync>d__10`1[[System.Decimal, System.Private.CoreLib]], xunit.core]](<RunAsync>d__10`1<System.Decimal> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs @ 35]

00007000102EEAE0 000000011C4C2EB6 Xunit.Sdk.ExceptionAggregator.RunAsync[[System.Decimal, System.Private.CoreLib]](System.Func`1<System.Threading.Tasks.Task`1<System.Decimal>>)

00007000102EEB30 000000011C4C2E11 Xunit.Sdk.TestInvoker`1[[System.__Canon, System.Private.CoreLib]].RunAsync() [/_/src/xunit.execution/Sdk/Frameworks/Runners/TestInvoker.cs @ 157]

00007000102EEB60 000000011C4C27D5 Xunit.Sdk.XunitTestRunner.InvokeTestMethodAsync(Xunit.Sdk.ExceptionAggregator) [/_/src/xunit.execution/Sdk/Frameworks/Runners/XunitTestRunner.cs @ 84]

00007000102EEBF0 000000011C4C243C Xunit.Sdk.XunitTestRunner+<InvokeTestAsync>d__4.MoveNext() [/_/src/xunit.execution/Sdk/Frameworks/Runners/XunitTestRunner.cs @ 67]

00007000102EECD0 000000011C4C1F9C System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Xunit.Sdk.XunitTestRunner+<InvokeTestAsync>d__4, xunit.execution.dotnet]](<InvokeTestAsync>d__4 ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilderCore.cs @ 38]

00007000102EED50 000000011C4C1E20 System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib]].Start[[Xunit.Sdk.XunitTestRunner+<InvokeTestAsync>d__4, xunit.execution.dotnet]](<InvokeTestAsync>d__4 ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs @ 35]

00007000102EED80 000000011C4C1DCF Xunit.Sdk.XunitTestRunner.InvokeTestAsync(Xunit.Sdk.ExceptionAggregator)

00007000102EEDE0 000000011C4C1A4A Xunit.Sdk.TestRunner`1+<>c__DisplayClass43_0[[System.__Canon, System.Private.CoreLib]].<RunAsync>b__0() [/_/src/xunit.execution/Sdk/Frameworks/Runners/TestRunner.cs @ 149]

00007000102EEE00 000000011C4C16F0 Xunit.Sdk.ExceptionAggregator+<RunAsync>d__10`1[[System.__Canon, System.Private.CoreLib]].MoveNext() [/_/src/xunit.core/Sdk/ExceptionAggregator.cs @ 107]

00007000102EEEC0 000000011C4C14C3 System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Xunit.Sdk.ExceptionAggregator+<RunAsync>d__10`1[[System.__Canon, System.Private.CoreLib]], xunit.core]](<RunAsync>d__10`1<System.__Canon> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilderCore.cs @ 38]

00007000102EEF50 000000011C4C13A0 System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib]].Start[[Xunit.Sdk.ExceptionAggregator+<RunAsync>d__10`1[[System.__Canon, System.Private.CoreLib]], xunit.core]](<RunAsync>d__10`1<System.__Canon> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs @ 35]

00007000102EEF90 000000011C4C12D6 Xunit.Sdk.ExceptionAggregator.RunAsync[[System.__Canon, System.Private.CoreLib]](System.Func`1<System.Threading.Tasks.Task`1<System.__Canon>>)

00007000102EF000 000000011C4C04E0 Xunit.Sdk.TestRunner`1+<RunAsync>d__43[[System.__Canon, System.Private.CoreLib]].MoveNext() [/_/src/xunit.execution/Sdk/Frameworks/Runners/TestRunner.cs @ 149]

00007000102EF180 000000011C4BF80D System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Xunit.Sdk.TestRunner`1+<RunAsync>d__43[[System.__Canon, System.Private.CoreLib]], xunit.execution.dotnet]](<RunAsync>d__43<System.__Canon> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilderCore.cs @ 38]

00007000102EF220 000000011C4BF720 System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib]].Start[[Xunit.Sdk.TestRunner`1+<RunAsync>d__43[[System.__Canon, System.Private.CoreLib]], xunit.execution.dotnet]](<RunAsync>d__43<System.__Canon> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs @ 35]

00007000102EF260 000000011C4BF68A Xunit.Sdk.TestRunner`1[[System.__Canon, System.Private.CoreLib]].RunAsync()

00007000102EF2D0 000000011C4BD870 Xunit.Sdk.XunitTestCaseRunner.RunTestAsync() [/_/src/xunit.execution/Sdk/Frameworks/Runners/XunitTestCaseRunner.cs @ 140]

00007000102EF370 000000011C4BD1B4 Xunit.Sdk.TestCaseRunner`1+<RunAsync>d__19[[System.__Canon, System.Private.CoreLib]].MoveNext() [/_/src/xunit.execution/Sdk/Frameworks/Runners/TestCaseRunner.cs @ 82]

00007000102EF460 000000011C4BCEB9 System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Xunit.Sdk.TestCaseRunner`1+<RunAsync>d__19[[System.__Canon, System.Private.CoreLib]], xunit.execution.dotnet]](<RunAsync>d__19<System.__Canon> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilderCore.cs @ 38]

00007000102EF4F0 000000011C4BCDD0 System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib]].Start[[Xunit.Sdk.TestCaseRunner`1+<RunAsync>d__19[[System.__Canon, System.Private.CoreLib]], xunit.execution.dotnet]](<RunAsync>d__19<System.__Canon> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs @ 35]

00007000102EF530 000000011C4BCD34 Xunit.Sdk.TestCaseRunner`1[[System.__Canon, System.Private.CoreLib]].RunAsync()

00007000102EF590 000000011C4BC3D0 Xunit.Sdk.XunitTestCase.RunAsync(Xunit.Abstractions.IMessageSink, Xunit.Sdk.IMessageBus, System.Object[], Xunit.Sdk.ExceptionAggregator, System.Threading.CancellationTokenSource) [/_/src/xunit.execution/Sdk/Frameworks/XunitTestCase.cs @ 162]

00007000102EF610 000000011C4BC29E Xunit.Sdk.XunitTestMethodRunner.RunTestCaseAsync(Xunit.Sdk.IXunitTestCase) [/_/src/xunit.execution/Sdk/Frameworks/Runners/XunitTestMethodRunner.cs @ 45]

00007000102EF660 000000011C4BBE40 Xunit.Sdk.TestMethodRunner`1+<RunTestCasesAsync>d__32[[System.__Canon, System.Private.CoreLib]].MoveNext() [/_/src/xunit.execution/Sdk/Frameworks/Runners/TestMethodRunner.cs @ 136]

00007000102EF770 000000011C4BBB5D System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Xunit.Sdk.TestMethodRunner`1+<RunTestCasesAsync>d__32[[System.__Canon, System.Private.CoreLib]], xunit.execution.dotnet]](<RunTestCasesAsync>d__32<System.__Canon> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilderCore.cs @ 38]

00007000102EF810 000000011C4BBA70 System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib]].Start[[Xunit.Sdk.TestMethodRunner`1+<RunTestCasesAsync>d__32[[System.__Canon, System.Private.CoreLib]], xunit.execution.dotnet]](<RunTestCasesAsync>d__32<System.__Canon> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs @ 35]

00007000102EF850 000000011C4BB9DA Xunit.Sdk.TestMethodRunner`1[[System.__Canon, System.Private.CoreLib]].RunTestCasesAsync()

00007000102EF8C0 000000011C4BB39C Xunit.Sdk.TestMethodRunner`1+<RunAsync>d__31[[System.__Canon, System.Private.CoreLib]].MoveNext() [/_/src/xunit.execution/Sdk/Frameworks/Runners/TestMethodRunner.cs @ 106]

00007000102EF9D0 000000011C4BB173 System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Xunit.Sdk.TestMethodRunner`1+<RunAsync>d__31[[System.__Canon, System.Private.CoreLib]], xunit.execution.dotnet]](<RunAsync>d__31<System.__Canon> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilderCore.cs @ 38]

00007000102EFA60 000000011C4BB090 System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib]].Start[[Xunit.Sdk.TestMethodRunner`1+<RunAsync>d__31[[System.__Canon, System.Private.CoreLib]], xunit.execution.dotnet]](<RunAsync>d__31<System.__Canon> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs @ 35]

00007000102EFAA0 000000011C4BAFF5 Xunit.Sdk.TestMethodRunner`1[[System.__Canon, System.Private.CoreLib]].RunAsync()

00007000102EFB00 000000011C4BAB93 Xunit.Sdk.XunitTestClassRunner.RunTestMethodAsync(Xunit.Abstractions.ITestMethod, Xunit.Abstractions.IReflectionMethodInfo, System.Collections.Generic.IEnumerable`1<Xunit.Sdk.IXunitTestCase>, System.Object[]) [/_/src/xunit.execution/Sdk/Frameworks/Runners/XunitTestClassRunner.cs @ 199]

00007000102EFB90 000000011C4B9130 Xunit.Sdk.TestClassRunner`1+<RunTestMethodsAsync>d__38[[System.__Canon, System.Private.CoreLib]].MoveNext()

00007000102EFEA0 000000011C4B88E7 System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Xunit.Sdk.TestClassRunner`1+<RunTestMethodsAsync>d__38[[System.__Canon, System.Private.CoreLib]], xunit.execution.dotnet]](<RunTestMethodsAsync>d__38<System.__Canon> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilderCore.cs @ 38]

00007000102EFF40 000000011C4B87F0 System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib]].Start[[Xunit.Sdk.TestClassRunner`1+<RunTestMethodsAsync>d__38[[System.__Canon, System.Private.CoreLib]], xunit.execution.dotnet]](<RunTestMethodsAsync>d__38<System.__Canon> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs @ 35]

00007000102EFF80 000000011C4B8759 Xunit.Sdk.TestClassRunner`1[[System.__Canon, System.Private.CoreLib]].RunTestMethodsAsync()

00007000102EFFF0 000000011C4B6902 Xunit.Sdk.TestClassRunner`1+<RunAsync>d__37[[System.__Canon, System.Private.CoreLib]].MoveNext() [/_/src/xunit.execution/Sdk/Frameworks/Runners/TestClassRunner.cs @ 175]

00007000102F0110 000000011C4B65C9 System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Xunit.Sdk.TestClassRunner`1+<RunAsync>d__37[[System.__Canon, System.Private.CoreLib]], xunit.execution.dotnet]](<RunAsync>d__37<System.__Canon> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilderCore.cs @ 38]

00007000102F01A0 000000011C4B64E0 System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib]].Start[[Xunit.Sdk.TestClassRunner`1+<RunAsync>d__37[[System.__Canon, System.Private.CoreLib]], xunit.execution.dotnet]](<RunAsync>d__37<System.__Canon> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs @ 35]

00007000102F01E0 000000011C4B6444 Xunit.Sdk.TestClassRunner`1[[System.__Canon, System.Private.CoreLib]].RunAsync()

00007000102F0240 000000011C4B5F0C Xunit.Sdk.XunitTestCollectionRunner.RunTestClassAsync(Xunit.Abstractions.ITestClass, Xunit.Abstractions.IReflectionTypeInfo, System.Collections.Generic.IEnumerable`1<Xunit.Sdk.IXunitTestCase>) [/_/src/xunit.execution/Sdk/Frameworks/Runners/XunitTestCollectionRunner.cs @ 185]

00007000102F02D0 000000011C4B5400 Xunit.Sdk.TestCollectionRunner`1+<RunTestClassesAsync>d__28[[System.__Canon, System.Private.CoreLib]].MoveNext()

00007000102F04D0 000000011C4B4CDD System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Xunit.Sdk.TestCollectionRunner`1+<RunTestClassesAsync>d__28[[System.__Canon, System.Private.CoreLib]], xunit.execution.dotnet]](<RunTestClassesAsync>d__28<System.__Canon> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilderCore.cs @ 38]

00007000102F0570 000000011C4B4BF0 System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib]].Start[[Xunit.Sdk.TestCollectionRunner`1+<RunTestClassesAsync>d__28[[System.__Canon, System.Private.CoreLib]], xunit.execution.dotnet]](<RunTestClassesAsync>d__28<System.__Canon> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs @ 35]

00007000102F05B0 000000011C4B4B5A Xunit.Sdk.TestCollectionRunner`1[[System.__Canon, System.Private.CoreLib]].RunTestClassesAsync()

00007000102F0620 000000011C4B2EB3 Xunit.Sdk.TestCollectionRunner`1+<RunAsync>d__27[[System.__Canon, System.Private.CoreLib]].MoveNext() [/_/src/xunit.execution/Sdk/Frameworks/Runners/TestCollectionRunner.cs @ 101]

00007000102F0740 000000011C4B2579 System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Xunit.Sdk.TestCollectionRunner`1+<RunAsync>d__27[[System.__Canon, System.Private.CoreLib]], xunit.execution.dotnet]](<RunAsync>d__27<System.__Canon> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilderCore.cs @ 38]

00007000102F07D0 000000011C4B2490 System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib]].Start[[Xunit.Sdk.TestCollectionRunner`1+<RunAsync>d__27[[System.__Canon, System.Private.CoreLib]], xunit.execution.dotnet]](<RunAsync>d__27<System.__Canon> ByRef) [/_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs @ 35]

00007000102F0810 000000011C4B2314 Xunit.Sdk.TestCollectionRunner`1[[System.__Canon, System.Private.CoreLib]].RunAsync()

00007000102F0870 000000011C4B182A Xunit.Sdk.XunitTestAssemblyRunner.RunTestCollectionAsync(Xunit.Sdk.IMessageBus, Xunit.Abstractions.ITestCollection, System.Collections.Generic.IEnumerable`1<Xunit.Sdk.IXunitTestCase>, System.Threading.CancellationTokenSource) [/_/src/xunit.execution/Sdk/Frameworks/Runners/XunitTestAssemblyRunner.cs @ 262]

00007000102F08E0 000000011C4B1744 Xunit.Sdk.XunitTestAssemblyRunner+<>c__DisplayClass14_2.<RunTestCollectionsAsync>b__2() [/_/src/xunit.execution/Sdk/Frameworks/Runners/XunitTestAssemblyRunner.cs @ 211]

00007000102F0920 0000000118DE7561 System.Threading.Tasks.Task`1[[System.__Canon, System.Private.CoreLib]].InnerInvoke() [/_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Future.cs @ 501]

00007000102F0940 0000000118BBF8AF System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) [/_/src/libraries/System.Private.CoreLib/src/System/Threading/ExecutionContext.cs @ 179]

00007000102F0990 0000000118BD669F System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread) [/_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs @ 2345]

00007000102F0A10 0000000118BD64DA System.Threading.Tasks.Task.ExecuteEntry() [/_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs @ 2258]

00007000102F0A30 0000000118BDECB5 System.Threading.Tasks.SynchronizationContextTaskScheduler+<>c.<.cctor>b__8_0(System.Object) [/_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskScheduler.cs @ 606]

00007000102F0A40 000000011C4B1683 Xunit.Sdk.MaxConcurrencySyncContext.RunOnSyncContext(System.Threading.SendOrPostCallback, System.Object) [/_/src/xunit.execution/Sdk/MaxConcurrencySyncContext.cs @ 106]

00007000102F0A70 000000011C4B1538 Xunit.Sdk.MaxConcurrencySyncContext+<>c__DisplayClass11_0.<WorkerThreadProc>b__0(System.Object) [/_/src/xunit.execution/Sdk/MaxConcurrencySyncContext.cs @ 96]

00007000102F0AB0 0000000118BBF8AF System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) [/_/src/libraries/System.Private.CoreLib/src/System/Threading/ExecutionContext.cs @ 179]

00007000102F0B00 000000011C4B14A8 Xunit.Sdk.ExecutionContextHelper.Run(System.Object, System.Action`1<System.Object>) [/_/src/xunit.execution/Sdk/Utility/ExecutionContextHelper.cs @ 110]

00007000102F0B30 000000011C4AF293 Xunit.Sdk.MaxConcurrencySyncContext.WorkerThreadProc() [/_/src/xunit.execution/Sdk/MaxConcurrencySyncContext.cs @ 96]

00007000102F0BB0 000000011BB9FD43 Xunit.Sdk.XunitWorkerThread+<>c.<QueueUserWorkItem>b__5_0(System.Object) [/_/src/common/XunitWorkerThread.cs @ 37]

00007000102F0BF0 0000000118BBF8AF System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) [/_/src/libraries/System.Private.CoreLib/src/System/Threading/ExecutionContext.cs @ 179]

00007000102F0C40 0000000118BD669F System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread) [/_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs @ 2345]

00007000102F0CC0 0000000118BB6F9F System.Threading.Thread.StartCallback() [/_/src/coreclr/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs @ 105]

00007000102F0E98 000000010fc642c1 [DebuggerU2MCatchHandlerFrame: 00007000102f0e98]                                                                                                                                       

Reproduction Steps

My original repro uses a fork of /src/libraries/Common/tests/System/Security/Cryptography/X509Certificates/CertificateAuthority.cs and is complicated.

I simplified the repro with a copy of /src/libraries/Common/tests/System/Security/Cryptography/X509Certificates/CertificateAuthority.cs and the following unit test:

using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography.X509Certificates.Tests.Common;

namespace Repro
{
    public class TestClass
    {
        [Fact]
        public void TestMethod()
        {
            CertificateAuthority.BuildPrivatePki(
                PkiOptions.AllRevocation,
                out RevocationResponder revocationResponder,
                out CertificateAuthority rootCa,
                out CertificateAuthority intermediateCa,
                out X509Certificate2 endEntity,
                testName: "test signer",
                registerAuthorities: true);

            revocationResponder.Dispose();
            rootCa.Dispose();
            intermediateCa.Dispose();
            endEntity.Dispose();
        }
    }
}

Note that this only hangs on macOS x64. The same repro on macOS amd64 works fine. It also works fine on Windows and Linux.

Expected behavior

No hang.

Actual behavior

Hang almost every time.

Regression?

Yes, but I cannot pinpoint a specific change. This succeeded on June 18th, 2024 with .NET SDK 8.0.302, still on macOS 12.7.5 x64. Subsequent runs started failing.

I don't want to imply that the regression was from moving from 8.0.302 to 8.0.303, since the first failure was on 8.0.302.

Known Workarounds

No response

Configuration

macOS 12.7.5 x64 .NET SDK 8.0.303

Other information

I have a MacBook Air also running macOS 12.7.5 x64 and cannot reproduce the hang locally.

dotnet-policy-service[bot] commented 1 month ago

Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones See info in area-owners.md if you want to be subscribed.

bartonjs commented 1 month ago

https://github.com/dotnet/runtime/blob/676189ad5e60ce6ed3337120f29470bff38bad8d/src/native/libs/System.Security.Cryptography.Native.Apple/pal_signverify.c#L154C9-L222 doesn't have any loops in it; the most likely place for it to be hanging is SecKeyCreateSignature.

It seems like Apple's Crypto stack is gummed up. I assume you've rebooted since the failure?

I'm not sure there's anything we can do here... but maybe @vcsjones or @filipnavara have suggestions/insights?

dtivel commented 1 month ago

@bartonjs, they're CI machines in a macOS machine pool. I don't have reboot capabilities. Furthermore, per AzDO logs, the failures are not isolated to one machine; it's multiple.

filipnavara commented 1 month ago

We have often seen similar issue when there was an interactive UI asking to unlock the keychain (which is obviously not visible on CI and requires remote access to the machine). The access to the keychain can be unlocked using the security tool from command line / CI script. We also observed that after macOS updates the password for the default keychain gets reset if you change it manually to something like empty password. Like OP, this appeared to be inconsistent between our macOS x64 and macOS arm64 (self-hosted) CI machines.

vcsjones commented 1 month ago

A blocking keychain modal does seem like the most plausible culprit here.

I simplified the repro with a copy of

When you repro'ed, were you SSHed or Remote Screen Sharing in to the Mac, or were you actually logged-in in front of the computer?

dtivel commented 1 month ago

The access to the keychain can be unlocked using the security tool from command line / CI script.

@filipnavara, with the security unlock-keychain command, what file path would I provide? Note my repro where I'm using CertificateAuthority to create RSA keys on the fly. I'm not trying to access anything persistent.

When you repro'ed, were you SSHed or Remote Screen Sharing into the Mac, or were you actually logged-in in front of the computer?

@vcsjones, this is entirely within a CI pipeline context. I'm not remoted into any machine. I'm just queuing builds, which run tests and hit this problem.

filipnavara commented 1 month ago

There’s no path, the default is the login keychain. This is literally the code in our script: security unlock-keychain -p "${{ secrets.AGENT_KEYCHAIN_PASSWORD }}". Note that macOS keychain APIs (and the .NET X509 APIs by proxy) often use the keychain even if you don’t store the actual keys. It may create temporary keychains which should be unique and unlocked but YMMV.

jeffhandley commented 1 month ago

@dtivel This issue isn't currently actionable for us. Please let us know if you identify a cause other than a blocking keychain modal.

dotnet-policy-service[bot] commented 1 month ago

This issue has been marked needs-author-action and may be missing some important information.

dotnet-policy-service[bot] commented 2 weeks ago

This issue has been automatically marked no-recent-activity because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will remove no-recent-activity.

dotnet-policy-service[bot] commented 3 days ago

This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.