split -n leaves bytes from a previous run in chunks that should be empty

オープン 初心者向け
#16,737 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@costajohnt がすでに取り組んでいます。

2026年11月20日 から。

  • #16738 @costajohnt による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
85/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust
領域
cli

調査の方向性

split.rsの出力初期化付近(876–893行)とバイトループ(1074–1090行)を確認し、既存の低ファイルディスクリプター数テストを読んでください。長い最初の入力にプレフィックスを再利用し、低いファイルディスクリプター上限のもとで1バイトの2番目の入力を使って再現してください。2番目のセットを再構成すると2番目の入力だけになることを確認する回帰チェックを追加し、その後、関連するsplitテストを実行してください。

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

説明

U - split

Running split -n 20 twice with the same prefix can produce 20 files and exit 0 both times, yet reassembling the second set returns data from the first input.

(
  cd "$(mktemp -d)" || exit 1
  export LC_ALL=C
  printf %s ABCDEFGHIJKLMNOPQRST | (ulimit -n 12 && split -n 20) || exit 1
  printf %s '!' | (ulimit -n 12 && split -n 20) || exit 1
  cat x??
)

GNU 9.12 prints !. On Linux x86_64, uutils 0.12.0 and main at 276ffe9cc02902b5ef32fe09dd0da7ec955de773 both print !JKLMNOPQRST. All 20 paths exist in both cases. The second input is one byte, so the remaining 19 chunks should be empty. I also reproduced this with 1,100 chunks and a descriptor limit of 1,024. Reassembly returned 80 bytes for a one-byte input.

Output initialization (split.rs lines 876–893) defers files it cannot open. A deferred file is retried when it receives data, but the byte loop exits (lines 1074–1090) when the input runs out. That leaves the previous contents of deferred empty chunks intact. In a fresh directory, those paths are missing altogether.

The existing low-descriptor test uses 100 lines for 40 round-robin chunks, so every chunk receives data. Reusing a prefix with a shorter second input and checking the reassembled bytes would catch this case.

主要言語
Rust
スター
24.4k
フォーク
2.2k
平均マージ
2日 23時間
マージ済み PR(30日)
402

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

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

uutils/coreutils のほかの issue

uutils/coreutils の issue をすべて見る

似ている issue

Rust の issue をもっと見る

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

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