-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix SslStreamCertificateContext OCSP test failures #100644
Fix SslStreamCertificateContext OCSP test failures #100644
Conversation
src/libraries/System.Net.Security/src/System/Net/Security/SslStreamCertificateContext.Linux.cs
Outdated
Show resolved
Hide resolved
TaskCompletionSource<byte[]?> completionSource = new TaskCompletionSource<byte[]?>(); | ||
|
||
ArraySegment<char> rentedChars = UrlBase64Encoding.RentEncode(encoded); | ||
byte[]? ret = null; | ||
_pendingDownload = completionSource.Task; | ||
FetchOcspAsyncCore(completionSource); | ||
return completionSource.Task; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does anything bad happen if something starts waiting on _pendingDownload
while the TCS's task is still PendingActivation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't think of anything bad happening, if the TCS wasn't completed yet, then the behavior should be equivalent to waiting for a regular Task returned from an async method (rest of the calling async method being as continuation etc.)
src/libraries/System.Net.Security/tests/UnitTests/SslStreamCertificateContextOcspLinuxTests.cs
Outdated
Show resolved
Hide resolved
/azp run runtime-libraries-coreclr outerloop |
/azp list |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run runtime-coreclr jitstress |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run runtime-coreclr jitstressregs |
Azure Pipelines successfully started running 1 pipeline(s). |
CI looks good the reenabled tests did not fail again and other failures are unrelated |
* Fix SslStreamCertificateContext OCSP test failures * Fix code style * Remove unwanted change * fixup! Fix code style * fixup! Remove unwanted change
Fixes #97836.
Fixes #97779.
This PR fixes two data races and adds some internal logging (leftover from debugging, but I figured they can become useful in case we need to debug issues in this area in the future).
First data race was because of following pattern
Both assignments to
_pendingTask
are racing and some of the test failures in the past were due to_pendingTask = null
assignment finishing first.Second data race was test-only. Consider the function
The test assumed that if
GetOcspResponseAsync
does not finish synchronously (e.g. no cached OCSP response and new one is being downloaded), the method will always return null. However, it is possible that the task finishes between returning fromGetOcspResponseAsync
and checkingtask.IsCompletedSuccessfully
. The tests were adjusted to not depend on this.