WS3: Fix client lifecycle and thread safety
メンテナーはふだん 1 日以内に返信
@j7nw4r がすでに取り組んでいます。
2026年7月28日 から。
評価
この issue はまだ評価されていません。
説明
Summary
The C++ Event Hubs clients carry two data races and no defined behavior after close. ProducerClient::Close mutates the sender map without taking the lock that guards it. Processor::m_isRunning is a plain bool written on one thread and read on another. No public header states a concurrency guarantee, and use after close throws std::out_of_range from a map lookup.
Severity tags follow the key in #7252.
Motivation
The .NET clients document safe concurrent use, close is idempotent, and a closed client throws EventHubsException with FailureReason.ClientClosed (sdk/eventhub/Azure.Messaging.EventHubs/src/EventHubsException.cs:227).
In C++, ProducerClient::Close iterates and clears m_senders without taking m_sendersLock (src/producer_client.cpp:36-69), while EnsureSender mutates the same map under that lock (src/producer_client.cpp:196-229). A concurrent Send and Close is a data race. Close also clears m_sessions and m_connections unguarded. No closed-state flag exists, so use after close reaches m_senders.at(...) and throws std::out_of_range (src/producer_client.cpp:230-234), which is a standard library error rather than a library error the caller can act on.
Processor::Start writes m_isRunning after it starts the worker thread, Stop writes it from another thread (src/processor.cpp:64,71), and the worker reads it in its loop (src/processor.cpp:100). The member is a plain bool (inc/azure/messaging/eventhubs/processor.hpp:277), so that is an unsynchronized read and write.
No public header documents which methods are safe to call concurrently or what Close guarantees.
Proposal
- Make
ProducerClient::Closetakem_sendersLockbefore it iterates and clearsm_senders,m_sessions, andm_connections(src/producer_client.cpp:36-69,196-229). [GA blocker] - Make
Closeidempotent, add a closed-state flag, and make use after close throwEventHubsExceptioninstead ofstd::out_of_range(src/producer_client.cpp:230-234). Apply the same treatment toConsumerClient::Close. Reference: .NET raisesFailureReason.ClientClosed. [GA blocker] - Make
Processor::m_isRunningatomic, and set it before the worker thread starts (inc/azure/messaging/eventhubs/processor.hpp:277,src/processor.cpp:51-77,100). [GA blocker] - Document the concurrency contract for every public client type in the headers and the README: which methods are safe to call concurrently, and what
Closeguarantees. [GA quality bar] - Correct the log text in
ConsumerClient::Close, which says "Close producer client" (src/consumer_client.cpp:40). [GA quality bar]
Validation
- A thread sanitizer run over a concurrent send and close reports no race.
- A thread sanitizer run over a processor start and stop reports no race.
- Calling
Closetwice succeeds. - Calling
SendafterClosethrowsEventHubsException. - Every public client header states its concurrency guarantee.
- 主要言語
- C++
- スター
- 207
- フォーク
- 173
- 平均マージ
- 1日 10時間
- マージ済み PR(30日)
- 30
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Azure/azure-sdk-for-cpp のほかの issue
-
customer-reported needs-triage question
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Azure/azure-sdk-for-cpp#7435 ·
メンテナーはふだん 1 日以内に返信
-
bug EngSys
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
Azure/azure-sdk-for-cpp#7362 ·
メンテナーはふだん 1 日以内に返信
-
Client needs-team-attention Service Attention Storage
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Azure/azure-sdk-for-cpp#7347 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Client Event Hubs needs-team-attention Service Attention
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
Azure/azure-sdk-for-cpp#7333 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
DataLakeDirectoryClient::ListPaths() throws exception due to incorrect format used for date-time fields対応中かも @seanmcc-msft が今日担当しました。 オープンcustomer-reported needs-triage question
Azure/azure-sdk-for-cpp#7436 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
Azure/azure-sdk-for-cpp の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
mpfaffenberger/privateer_reimagined#658 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
microsoft/onnxruntime#33018 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
AXERA-TECH/ax-llm#81 ·
-
enhancement
難易度 2/5 半日 初心者へのやさしさ 78/100
ros-industrial/ros2_canopen#448 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信