UnixNetProcessor::connect_re allocates from another thread's freelist
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- cpp
- 領域
- backend, networking
調査の方向性
Start with the cited allocation and affinity paths in src/iocore/net/UnixNetProcessor.cc, then read the ownership rule in include/iocore/eventsystem/Thread.h and the cache operations in include/iocore/eventsystem/ProxyAllocator.h. Trace how THREAD_ALLOC_INIT behaves when the selected thread differs from the calling thread, including the TSNetConnect example in src/api/InkAPI.cc. Done means preventing access to another thread’s ProxyAllocator cache and handling the reported missing mutex check safely.
索引モデルが issue の本文から書いたものです。
説明
UnixNetProcessor::connect_re chooses the thread the new connection will run on with eventProcessor.assign_affinity_by_type(cont, opt.etype) (UnixNetProcessor.cc#L192-L193). It then allocates the NetVC from that thread's per-thread freelist, THREAD_ALLOC_INIT(netVCAllocator, t) (UnixNetProcessor.cc#L316).
assign_affinity_by_type returns the calling thread only if it already has the requested event type. Otherwise it returns the continuation's affinity thread or a newly assigned thread of that type (UnixEventProcessor.cc#L662-L677). The allocators have two layers, and only one of them is safe to share between threads. The global ClassAllocator freelists are lock-free and safe to use from any thread (ink_queue.cc#L206). In front of each global allocator, every Thread keeps a ProxyAllocator cache. That cache is a plain singly linked list, popped by thread_alloc and pushed by THREAD_FREE with no atomics or lock (ProxyAllocator.h#L54-L60, #L106-L119). It avoids the CAS on the hot path, and that is only safe because a single thread owns it. Thread.h states the rule: the Thread passed to the macros MUST be the calling OS thread's own Thread (Thread.h#L175-L177). THREAD_ALLOC_INIT only reaches the lock-free global list when that cache is empty. So a connect started from a thread that isn't ET_NET pops another thread's ProxyAllocator cache while that thread may be pushing to or popping from it. One example is a plugin calling TSNetConnect from an ET_TASK continuation (InkAPI.cc#L6774). This is a data race that can corrupt that cache, for example handing the same NetVC out twice.
assign_affinity_by_type also dereferences cont->mutex->thread_holding without a check (L664). It crashes if the caller doesn't hold the continuation's mutex.
A fix is to allocate from the current thread, or from the global allocator, when t != this_ethread().
generated with Claude Opus 5.5 by Josiah VanderZee
- 主要言語
- C++
- スター
- 2k
- フォーク
- 903
- 平均マージ
- 4日 4時間
- マージ済み PR(30日)
- 135
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/trafficserver のほかの issue
-
UnixNetVConnection::do_io_write with a null reader leaves the previous reader in the write VIO対応中かも @NginxL が今日担当しました。 オープンBug Good First Issue IOBuffer Network
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/trafficserver#14220 ·
メンテナーはふだん 2 日以内に返信
-
MallocAllocator does not check for allocation failure対応中かも @umrndem が今日担当しました。 オープンBug Core Good First Issue
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/trafficserver#14218 · コメント 2 件 ·
メンテナーはふだん 2 日以内に返信
-
Bug Event System Threads
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/trafficserver#14217 ·
メンテナーはふだん 2 日以内に返信
-
TSContScheduleEveryOnPool and TSContScheduleEveryOnThread accept a zero or negative period対応中かも @rajeetvk が 1 日前に担当しました。 オープンBug Event System Good First Issue TS API
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
apache/trafficserver#14214 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
HostDBContinuation::init memsets a polymorphic Action対応中かも @ANMOLSCRIPT が今日担当しました。 オープンBug Good First Issue HostDB
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
apache/trafficserver#14204 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
apache/trafficserver の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
メンテナーはふだん 2 日以内に返信
-
bug data-types
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
ClickHouse/clickhouse-cpp#645 ·
メンテナーはふだん 1 日以内に返信
-
bug compatibility difficulty:easy prio:normal
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
NatronGitHub/openfx-misc#524 ·
メンテナーはふだん 1 日以内に返信
-
documentation enhancement help wanted P0
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Awesome-Embedded-Learning-Studio/Tutorial_AwesomeModernCPP#359 ·
メンテナーはふだん 1 日以内に返信
-
Type: Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
openscad/openscad#7360 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信