Test failure: Manual_CertificateSentMatchesCertificateReceived_Success
The test as currently written fails sporadically on Windows. If, however, GC.Collect(); GC.WaitForPendingFinalizers(); is added inside the loop here: https://github.com/dotnet/corefx/blob/483aa5a3012fe78ea001ece1b0404b18c0b90a29/src/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.ClientCertificates.cs#L117
the reuseClient==false test fails deterministically for me with the error "The client certificate credentials were not recognized". It appears something is getting finalized and preventing the same certificate instance from being used with subsequent HttpClientHandler instances.
Failed on Ubuntu here: http://dotnet-ci.cloudapp.net/job/dotnet_corefx/job/master/job/ubuntu14.04_debug_prtest/2303/testReport/junit/System.Net.Http.Functional.Tests/HttpClientHandler_ClientCertificates_Test/Manual_CertificateSentMatchesCertificateReceived_Success_numberOfRequests__3__reuseClient__True_/
Stacktrace
MESSAGE:
System.Threading.Tasks.TaskCanceledException : A task was canceled.
+++++++++++++++++++
STACK TRACE:
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at System.Net.Http.Functional.Tests.HttpClientHandler_ClientCertificates_Test.<>c__DisplayClass5_0.<<Manual_CertificateSentMatchesCertificateReceived_Success>b__2>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at System.Net.Http.Functional.Tests.HttpClientHandler_ClientCertificates_Test.<>c__DisplayClass5_2.<<Manual_CertificateSentMatchesCertificateReceived_Success>b__4>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at System.Net.Test.Common.LoopbackServer.<>c__DisplayClass3_0.<CreateServerAsync>b__0(Task t) at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at System.Net.Http.Functional.Tests.HttpClientHandler_ClientCertificates_Test.<Manual_CertificateSentMatchesCertificateReceived_Success>d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Failed on Ubuntu again:
http://dotnet-ci.cloudapp.net/job/dotnet_corefx/job/master/job/ubuntu14.04_debug_prtest/2465/testReport/junit/System.Net.Http.Functional.Tests/HttpClientHandler_ClientCertificates_Test/Manual_CertificateSentMatchesCertificateReceived_Success_numberOfRequests__3__reuseClient__True_/
Failed on Ubuntu again
Thanks, but this is a different failure than the one highlighted. This is a timeout, whereas the other is some kind of data corruption due to finalization.
Sorry about that, you're right. Looks like both of my links are for a different root cause (and different OS).
I filed dotnet/corefx#9785 for the Ubuntu issue.
@stephentoub I have a theory about why this test is failing.
the reuseClient==false test fails deterministicly for me with the error "The client certificate credentials were not recognized". It appears something is getting finalized and preventing the same certificate instance from being used with subsequent HttpClientHandler instances.
The client certificate used in this test is a STATIC thing coming from here: https://github.com/dotnet/corefx/blob/master/src/Common/tests/System/Net/Configuration.Certificates.cs#L24
This client certificate is added to an instance of an X509Certificate2Collection object within a HttpClientHandler object. What are the dispose/finalization rules for X509Certificate2Collection? Does it dispose of things in the collection? If it does, this is why this is failing. The fix for this is to create instance copies of the client certificate instead of re-using a static object.
@bartonjs Can you comment on this?
cc: @CIPop
I think the best solution is probably to change Configuration.Certificate.cs so that it returns a new instance of the certificates.
It's ok for the DATA to create a certificate (server or client) to be a static thing. But the X509Certificate2 object itself that is returned should be a new instance copy.
@davidsh X509Certificate2Collection isn't inherently IDisposable; nothing would Dispose a cert unless you did it manually. That said, the X509Certificate tests do hold static data, and each test that wants the data clones it anew.
Fails on build 20161204.02. So adding "test-run-core" https://mc.dot.net/#/product/netcore/master/source/official~2Fcorefx~2Fmaster~2F/type/test~2Ffunctional~2Fcli~2F/build/20161204.02/workItem/System.Net.Http.Functional.Tests/analysis/xunit/System.Net.Http.Functional.Tests.HttpClientHandler_ClientCertificates_Test~2FManual_CertificateSentMatchesCertificateReceived_Success(numberOfRequests:%203,%20reuseClient:%20True)
Unhandled Exception of Type System.Threading.Tasks.TaskCanceledException
Message :
System.Threading.Tasks.TaskCanceledException : A task was canceled.
Stack Trace :
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at System.Net.Http.Functional.Tests.HttpClientHandler_ClientCertificates_Test.<>c__DisplayClass5_0.<<Manual_CertificateSentMatchesCertificateReceived_Success>b__2>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at System.Net.Http.Functional.Tests.HttpClientHandler_ClientCertificates_Test.<>c__DisplayClass5_2.<<Manual_CertificateSentMatchesCertificateReceived_Success>b__4>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at System.Net.Test.Common.LoopbackServer.<>c__DisplayClass3_0.<CreateServerAsync>b__0(Task t)
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at System.Net.Http.Functional.Tests.HttpClientHandler_ClientCertificates_Test.<Manual_CertificateSentMatchesCertificateReceived_Success>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Fails on build 20161227.01, please check: https://mc.dot.net/#/product/netcore/master/source/official~2Fcorefx~2Fmaster~2F/type/test~2Ffunctional~2Fcli~2F/build/20161227.01/workItem/System.Net.Http.Functional.Tests/analysis/xunit/System.Net.Http.Functional.Tests.HttpClientHandler_ClientCertificates_Test~2FManual_CertificateSentMatchesCertificateReceived_Success(numberOfRequests:%203,%20reuseClient:%20True)
Message:
System.Threading.Tasks.TaskCanceledException : A task was canceled.
Stack Trace:
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at System.Net.Http.Functional.Tests.HttpClientHandler_ClientCertificates_Test.<>c__DisplayClass5_0.<<Manual_CertificateSentMatchesCertificateReceived_Success>b__2>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at System.Net.Http.Functional.Tests.HttpClientHandler_ClientCertificates_Test.<>c__DisplayClass5_2.<<Manual_CertificateSentMatchesCertificateReceived_Success>b__4>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at System.Net.Test.Common.LoopbackServer.<>c__DisplayClass3_0.<CreateServerAsync>b__0(Task t)
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at System.Net.Http.Functional.Tests.HttpClientHandler_ClientCertificates_Test.<Manual_CertificateSentMatchesCertificateReceived_Success>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Tracking all System.Net intermittently failing bugs with dotnet/corefx#14519.
Reopening since it's being referenced by dotnet/corefx#16167
I believe there are two issues with this test:
- A cert was reused after it was gc'd and caused errors like "The client certificate credentials were not recognized". This was fixed with the creation of the cert every time through the loop https://github.com/dotnet/corefx/issues/15777
- The test fails with "a task has been canceled" or "The server returned an invalid or unrecognized response". This has not been fixed yet.
This is still active; may or may not be a test bug as the last attempt to fix resulted in occasional test hangs
Flagging this as product bug, not test bug. Adding a Task.Delay(1) at the end of makeAndValidateRequest() appears to mask the issue and avoid the occasional exception. Perhaps there is a timing or race condition stemming from calling LoopbackServer.AcceptSocketAsync for each run (with the same server).
This can be repro'd on Windows by changing the
[InlineData(6, false)]
[InlineData(3, true)]
to
[InlineData(600, false)]
[InlineData(300, true)]
or similar large value. I've found that locally only a single run is should raise an exception, although two may be needed.
@steveharter Do you still have a repro? (I couldn't repro with the above values - looks like this one is very tightly related to timings.)
I no longer have a local repro. I enabled the test, change the InlineData values and ran the suite 5 times without error (normally once was enough).
@steveharter can you please check if you hit it on the CI machine in a loop? If not, I guess we should close it as no repro, at least until next failure in CI. Thoughts?
I originally thought this might be dotnet/corefx#16516 which we currently believe it's caused by a Windows bug. This is happening on both Linux and Windows.
I can repro after running the HttpFunctional tests in a loop. Out of 32 runs, it repro'd twice.
What I did to repro:
- Comment out the [ActiveIssue(9543)]
- Change [InlineData] values from 6,3 to 666,333
- Run all of the HttpFunctional tests in a loop on my local Windows 10 machine
@CIPop needs some more traces - @steveharter can you please help? (@CIPop will try to repro locally first)