ShareableList corrupts multi-byte UTF-8 strings and bytes with trailing nulls
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
Bug description:
Issue
ShareableList allocates string slots based on character count instead of UTF-8 byte count, causing corruption for multi-byte characters. Additionally, rstrip(b'\x00') strips legitimate trailing null bytes from bytes values.
Note: The trailing null bytes issue was originally reported in #106939 (July 2023) and documented as a known issue with a workaround. This fix attempts to resolve both that long-standing issue and the newly discovered UTF-8 corruption bug.
Reproducer
from multiprocessing.shared_memory import ShareableList
# String corruption
sl = ShareableList(['0\U00010000\U00010000'])
print(sl[0]) # UnicodeDecodeError
sl.shm.close(); sl.shm.unlink()
# Bytes corruption
sl = ShareableList([b'\x00'])
print(repr(sl[0])) # b'' instead of b'\x00'
sl.shm.close(); sl.shm.unlink()
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
- gh-145266
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
エントリーポイント multiprocessing.shared_memory.ShareableList から始め、issue にある 2 つの再現スニペットを実行してください。マルチバイト文字列が引き続きデコード可能であり、bytes 値が末尾の null バイトを保持すれば完了です。作業はすでに進行中のため、開始前にリンク先の PR gh-145266 を確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- operating-systems
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 25/100