python / python/cpython

Tarfile extraction does not work on Windows

オープン
#95,763 コメント 6 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

3.10 3.11 3.12 OS-windows stdlib triaged type-bug
主要言語
Python
スター
77.2k
フォーク
36k
平均マージ
1日 9時間
マージ済み PR(30日)
558

説明

Using Python 3.10.5, there is a scenario where the extractall function of tarfile is causing an infinite loop for Python on Windows, but not in Linux.

The tar-file where the issue occurred was the one produced by docker export, where a file-system is saved as a tar file. Unfortunately, it is too big to upload here, so I will give some commands to get this file.

> docker create --name "testcontainer" tomcat
> docker export --output="testtomcat.tar" testcontainer

That should produce a file of about 457MB.

Now, using Python 3.10.5 under Windows, the following code-snippet will crash:

import tarfile
with tarfile.open("testtomcat.tar") as tarf:
     members_to_extract = [tar_info for tar_info in tarf.getmembers()
                                           if not tar_info.isdev()]
     tarf.extractall(path="/tmp/foo/", members=members_to_extract)

The error says: maximum recursion depth exceeded while calling a Python object

Your environment

  • CPython versions tested on: Python 3.10.5
  • Operating system and architecture: Windows 11 is where it failed, and it works fine with the same python version in Arch Linux with kernel Linux 5.15.58-2-lts x86_64

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

tarfile.extractall と、レポートに示されている members のフィルタリングから始め、次に docker create コマンドと docker export コマンドを使って Windows 上で動作を再現します。Linux 上で同じ Python バージョンを使った場合の展開結果と比較します。エクスポートされた tar アーカイブを、再帰深度の超過による失敗や無限ループなしに Windows 上で展開できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
docker, python
領域
operating-systems
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。