`_py_abc` Python implementation of `abc` is not thread-safe
オープン
まだ誰も着手していません。
stdlib
type-bug
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
The update to the invalidation counter is not thread-safe and can lose updates in some Python implementations:
Failures seen on:
- Python 3.14t
- Python 3.9
- pypy3.10
- pypy3.11
But not on Python 3.10-3.14 with GIL due to limited GIL switch opportunities.
For example, consider the following repro, adapted from test_abc.test_registration_basics:
import _py_abc as abc # Use Python implementation of ABCs!!
import threading
import os
import sys
sys.setswitchinterval(1e-6)
N = 5
def run(b):
b.wait()
class A(metaclass=abc.ABCMeta):
pass
A.register(int)
if not isinstance(42, A):
print("Oops!")
os._exit(1)
def main():
for _ in range(10000):
threads = []
b = threading.Barrier(N)
for _ in range(N):
t = threading.Thread(target=run, args=(b,))
threads.append(t)
t.start()
for t in threads:
t.join()
if __name__ == "__main__":
main()
Linked PRs
- gh-130131
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Lib/_py_abc.py の無効化カウンターの更新付近から始め、issue にあるスレッドを使った例で競合状態を再現します。Lib/test/test_abc.py、特に test_registration_basics を実行します。同時登録によって無効化の更新が失われなくなり、影響を受ける Python 実装が関連するテストに合格すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 25/100