[EXPORTER] Fixes tsan warnings#3531
Conversation
✅ Deploy Preview for opentelemetry-cpp-api-docs canceled.
|
There was a problem hiding this comment.
Pull Request Overview
This PR suppresses ThreadSanitizer warnings for callback_thread in HttpOperation by introducing a dedicated accessor with TSAN-ignore annotations and memory fences.
- Add
HttpOperationAccessorwithOPENTELEMETRY_SANITIZER_NO_THREADwrappers and memory fences aroundcallback_threadaccess. - Replace direct
async_data_->callback_threadreads/writes withHttpOperationAccessor::GetThreadId/SetThreadId. - Declare
HttpOperationAccessoras afriendin theHttpOperationclass header.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| ext/src/http/client/curl/http_operation_curl.cc | Introduces HttpOperationAccessor and replaces direct callback_thread accesses with accessor calls. |
| ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h | Adds friend class HttpOperationAccessor; to grant the accessor private access to HttpOperation::AsyncData. |
Comments suppressed due to low confidence (2)
ext/src/http/client/curl/http_operation_curl.cc:53
- [nitpick] It may be helpful to add a brief comment explaining why
OPENTELEMETRY_SANITIZER_NO_THREADis applied here, clarifying the intent to silence TSAN warnings for this accessor.
OPENTELEMETRY_SANITIZER_NO_THREAD static std::thread::id GetThreadId(
ext/src/http/client/curl/http_operation_curl.cc:360
- Consider adding unit tests that verify
callback_threadis correctly set, read, and reset through the accessor functions to prevent regressions in callback synchronization.
if (HttpOperationAccessor::GetThreadId(*async_data_) != std::this_thread::get_id())
| @@ -47,6 +47,28 @@ namespace client | |||
| namespace curl | |||
| { | |||
|
|
|||
There was a problem hiding this comment.
[nitpick] Consider placing HttpOperationAccessor in an anonymous namespace since it’s only used within this translation unit, to avoid exporting an internal utility.
| namespace | |
| { |
There was a problem hiding this comment.
anonymous namespace will break the friend access.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3531 +/- ##
==========================================
- Coverage 90.03% 90.00% -0.02%
==========================================
Files 220 220
Lines 7069 7069
==========================================
- Hits 6364 6362 -2
- Misses 705 707 +2 🚀 New features to boost your workflow:
|
marcalff
left a comment
There was a problem hiding this comment.
Thanks for the patch.
See some questions on the ifdef logic.
Fixes #3530
Changes
callback_threadhas data race inHttpOperation. So just ignore it.For significant contributions please make sure you have completed the following items:
CHANGELOG.mdupdated for non-trivial changes