Repository navigation
[TEST] Cancel from the IO thread in the curl cancel cases - #4376
Merged
marcalff merged 2 commits intoAug 7, 2026
Merged
Conversation
ACancelBeforeTheResponseReportsCancelled cancelled from the test thread while the IO thread was driving the easy handle, and TSAN caught Abort's curl_easy_setopt against Curl_resolv. The client side is open-telemetry#4375. Nothing listens on 19937, so the connection fails and PerformCurlMessage dispatches ConnectFailed from the IO thread. Cancelling there still leaves the state short of Response with the abort flag raised, which is what the completion callback's WasAborted arm needs, and Abort now runs on the thread that owns the handle. Both cases record the thread they cancelled on and assert it is not the test thread, so a later edit cannot move it back without failing.
Member
|
Added blocking label: this fix needs to merge, to restore a working CI for tsan builds. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4376 +/- ##
=======================================
Coverage 81.77% 81.77%
=======================================
Files 493 493
Lines 19456 19456
=======================================
Hits 15909 15909
Misses 3547 3547 🚀 New features to boost your workflow:
|
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4369. The client side is #4375, which this does not touch.
ACancelBeforeTheResponseReportsCancelledcancelled from the test thread while the IO thread was driving the easy handle, so TSAN sawAbort()'scurl_easy_setoptagainstCurl_resolv. Per your note, this works around it in the test and leaves the client to the other issue.What it does instead
Nothing listens on 19937, so the connection fails and
PerformCurlMessagedispatchesConnectFailedfrom the IO thread. Cancelling from that event still leaves the state short ofResponsewith the abort flag raised, which is what the completion callback'sWasAborted()arm needs, andAbort()now runs on the thread that owns the handle. The sibling case already cancelled fromOnEvent(Response), which was on the IO thread too, so both are consistent now.It also drops the
mtx_requestshold, since the case no longer needs to keep the server quiet.It still covers what it was written for
The point of the case is the
else if (operation.WasAborted())arm, which nothing exercised before it and which Codecov had flagged. Deleting that arm still turns it red:Cancelledis still counted by its empty reason rather than by any cancel, sinceCleanup()dispatches one of its own carrying a curl message andGetCurlErrorMessagenever returns an empty string. One difference worth noting: on this pathCleanup()seesConnectFailedrather than an in flight state, so it does not add a secondCancelled, and the total is one instead of two.Both cases now record the thread they cancelled on and assert it is not the test thread, so a later edit cannot move the cancel back to the caller without failing.
Checks
22 of 22 in
curl_http_testagainst unmodifiedmain, clang-format clean, clean underOTELCPP_MAINTAINER_MODE=ON. Three TSAN runs of the two cases are clean, though I would not read much into that: I could not reproduce the original race here either, twelve runs including one aimed at a slow resolving host.No
CHANGELOG.mdentry, since nothing user visible changes.