Skip to content

Queue RevocationResponder work items to the global thread pool queue - #136022

Merged
rzikm merged 1 commit into
dotnet:mainfrom
pcshrosbree:fix/revocationresponder-global-queue
Oct 19, 2026
Merged

rzikm merged 1 commit into
dotnet:mainfrom
pcshrosbree:fix/revocationresponder-global-queue

Conversation

@pcshrosbree

Copy link
Copy Markdown
Contributor

RevocationResponder is the loopback OCSP/CRL server used by the revocation tests. Under thread-pool load it can stop answering requests until the chain engine's fetch times out. When that happens, CertificateValidationRemoteServer.ConnectWithRevocation_WithCallback(checkRevocation: True) sees RevocationStatusUnknown instead of Revoked.

Fixes #134230

Cause

The responder runs its accept loop as one thread-pool work item. Throughout the listener's lifetime, that work item waits for requests in HttpListener.GetContext(). Each accepted request was queued with preferLocal: true:

ThreadPool.QueueUserWorkItem(state => HandleRequest(state), context, true);

On a pool thread, preferLocal: true pushes the item into that thread's local queue. Here that thread goes straight back into GetContext(), so the handler runs only if another worker steals it. ThreadPoolWorkQueue.Dequeue steals only after the local, high-priority and global queues come up empty. So while the rest of the test process keeps the global queue busy, the OCSP and CRL requests sit unanswered. trustd gives up after its fixed 3-second per-fetch timer on macOS, and CryptoAPI after its per-URL timeout on Windows.

This matches the failures linked from the issue's report. Of the report's 47 rows, 30 have links that still resolve: 25 are for OSX.26.Arm64.Open, 3 are for Windows x86 checked, and 2 are for macOS 15 x64. In the six failing work items I downloaded:

  • macOS reports Collection: [RevocationStatusUnknown], and Windows reports [RevocationStatusUnknown, OfflineRevocation].
  • The case takes about 10 to 15 seconds on macOS and 48 seconds on Windows x86. In build 1638535, the same case passes on 16 other legs in 0.12 to 8.4 seconds.
  • This test is the only failure in each of those work items.

Change

Queue the accept loop and the request handlers with preferLocal: false, and add a comment explaining why. The change is test-only and applies to every test project that compiles RevocationResponder, including System.Net.Http, System.Net.Mail, System.Net.Quic, System.Net.Security and System.Security.Cryptography.

Validation

I couldn't run the macOS or Windows legs locally. Instead I used a small console app on Linux x64 (32 cores) that compiles the real CertificateAuthority.cs and RevocationResponder.cs. It builds the same PKI as the test (OCSP for the end entity, CRLs everywhere, one intermediate, revoked leaf), then builds the chain with Online, EndCertificateOnly, CustomRootTrust and UrlRetrievalTimeout = 3s. Meanwhile, CPU-bound work items keep re-queueing themselves to the global queue. The table shows the results at different loads:

Global-queue load (items × work duration per item) Before After
idle 5/5 Revoked 5/5 Revoked
24 items (fewer than the workers) 5/5 Revoked 5/5 Revoked
40 items × 5 ms 2/10 RevocationStatusUnknown 10/10 Revoked
64 items × 5 ms 10/10 RevocationStatusUnknown 10/10 Revoked
128 items × 20 ms 10/10 RevocationStatusUnknown 10/10 Revoked

Before the change, each failing chain build in the local repro takes about 6 seconds, consistent with two 3-second fetch timeouts. Its leaf status is [RevocationStatusUnknown, OfflineRevocation], the same as the Windows CI failure. In the recorded runs after the change, all three queueing sites use preferLocal: false. Changing the accept-loop flag as well is a precaution against the same starvation when the thread that creates the responder then blocks synchronously.

This shows the mechanism and that the change removes it. Whether CI processes reach this level of global-queue saturation is inferred from the timings above, not measured.

Note

This change was prepared with AI assistance (Anthropic Claude, checked by OpenAI Codex) at my request. I reviewed the change and the measurements before opening.

RevocationResponder runs its accept loop on a thread pool thread that
blocks in HttpListener.GetContext for the lifetime of the listener.
Previously, it queued each request handler with preferLocal: true. That
puts the handler in the local queue of the blocked thread, where it can
only run if another worker steals it, and workers only steal once the
global queue is empty.

When the test process keeps the global queue busy, the OCSP or CRL
request is not answered before the platform's fetch timeout (3 seconds
per fetch in trustd on macOS), and the chain reports
RevocationStatusUnknown instead of Revoked. This is the likely cause of
the failures in
CertificateValidationRemoteServer.ConnectWithRevocation_WithCallback;
queue saturation in CI has not been measured.

Queue the accept loop and the request handlers with preferLocal: false.

Fixes dotnet#134230
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Oct 18, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @VSadov
See info in area-owners.md if you want to be subscribed.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@rzikm rzikm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks!

@rzikm
rzikm merged commit 4353757 into dotnet:main Oct 19, 2026
102 of 104 checks passed
@pcshrosbree

Copy link
Copy Markdown
Contributor Author

Thank you for the review and the merge.

@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Oct 20, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Net.Security community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System.Net.Security.Tests.CertificateValidationRemoteServer.ConnectWithRevocation_WithCallback fails with Assert.Contains() Failure

3 participants