execFileSync piped Buffer input intermittently delivers all bytes but no EOF on macOS arm64
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- javascript, node.js
調査の方向性
Start by reading the execFileSync implementation in lib/child_process.js and its synchronous pipe handling, then trace the related libuv code for writing piped input and closing the pipe on macOS arm64. Reproduce with the supplied C reader on macOS arm64 and check existing child process tests for coverage of finite Buffer input and EOF. Done when the reader reliably receives EOF after all input and a regression test covers the race.
索引モデルが issue の本文から書いたものです。
説明
Version
v22.21.1, libuv 1.51.0
Platform
macOS 26.6.2 (25G83), arm64
Subsystem
child_process / synchronous piped stdin shutdown (possibly libuv or macOS; exact internal cause not yet established)
What steps will reproduce the bug?
Save this as repro.mjs and run node repro.mjs on macOS arm64 with the system C compiler available. All input is synthetic. There is no Git, repository, network, credential, or application configuration dependency.
import { execFileSync } from 'node:child_process';
import { mkdtempSync, rmSync } from 'node:fs';
import { join } from 'node:path';
import { tmpdir } from 'node:os';
const dir = mkdtempSync(join(tmpdir(), 'node-sync-eof-'));
try {
const reader = join(dir, 'reader');
execFileSync('/usr/bin/cc', ['-x', 'c', '-', '-o', reader], {
input: `#include <unistd.h>
#include <stdio.h>
int main(void) {
/* Startup work exposes the scheduling race without sleeping. */
for (int i = 0; i < 100000; i++) getpid();
char buffer[12311];
size_t total = 0;
for (;;) {
ssize_t n = read(0, buffer, sizeof(buffer));
if (n < 0) return 2;
if (n == 0) { fprintf(stderr, "EOF %zu\\n", total); return 0; }
total += n;
fprintf(stderr, "READ %zu\\n", total);
}
}`,
});
const input = Buffer.alloc(173555, 120);
for (let i = 0; i < 2000; i++) {
try {
execFileSync(reader, [], {
input,
stdio: ['pipe', 'pipe', 'pipe'],
maxBuffer: 256 * 1024 * 1024,
timeout: 3000, // Watchdog only: terminates a stuck reader.
});
} catch (error) {
console.error({ iteration: i, code: error.code, signal: error.signal,
stderr: error.stderr?.toString() });
process.exitCode = 1;
break;
}
}
} finally {
rmSync(dir, { recursive: true, force: true });
}
How often does it reproduce? Is there a required condition?
Intermittent. This generic reader reproduced at iteration 266 in the first 2000-iteration run. The startup work matters for exposing the race: a simpler immediate C reader completed 1500 iterations, and a Node child reader completed 1000. One-shot tests often succeed. The timeout only prevents a hung child from blocking the probe indefinitely; it is not an expected completion-time assertion.
The original downstream symptom involved repeated execFileSync('git', ['hash-object', '-w', '--stdin'], { input, stdio: ['pipe','pipe','pipe'], maxBuffer: 256*1024*1024 }) with no timeout. The owned child remained blocked for about 20 minutes before being terminated. Synthetic Git loops independently reproduced with and without -w, using both Homebrew Git 2.50.1 and Apple /usr/bin/git. Therefore this is not tied to object database writes. A sample of a synthetic stuck Git process showed hash_fd -> index_fd -> strbuf_read -> read_in_full -> xread -> read.
What is the expected behavior? Why is that the expected behavior?
After the finite Buffer has been delivered, stdin should reach EOF and the child should return. The documented input Buffer option with piped stdio should be sufficient; there is no asynchronous stdin stream for the synchronous caller to end manually.
Version-specific documentation: https://github.com/nodejs/node/blob/v22.21.1/doc/api/child_process.md#child_processexecfilesyncfile-args-options
What do you see instead?
The generic reader receives all 173555 bytes, then blocks waiting for EOF. The parent eventually terminates it through the watchdog:
{ iteration: 266, code: 'ETIMEDOUT', signal: 'SIGTERM', stderr:
'READ 12311\nREAD 24622\nREAD 36933\nREAD 49244\nREAD 61555\n' +
'READ 65536\nREAD 77847\nREAD 90158\nREAD 102469\nREAD 114780\n' +
'READ 127091\nREAD 131072\nREAD 143383\nREAD 155694\nREAD 168005\n' +
'READ 173555\n' }
There is no EOF 173555 line on the failed iteration. Output is far below maxBuffer. The timeout cleanly terminates the child, and the owned fixture is removed.
Additional information
No Node/Git/installed dependency patches or downstream transport workarounds have been applied. I have not yet verified a fixed Node release. Latest published Node 22 release metadata still reports libuv 1.51.0; that does not prove whether the latest patch is affected. The precise Node/libuv/macOS internal cause remains to be established.
Downstream report: https://github.com/Shufflewick/agent-policy/issues/206
The exact embedded reproducer was extracted and rerun unchanged: it reproduced again at iteration 679, with all 173555 bytes logged and no EOF before the watchdog.
Reporter: @rizen. Self-assignment was requested, but GitHub rejected it (could not assign user: 'rizen' not found); this external repository does not permit assigning the reporter.
- 主要言語
- JavaScript
- スター
- 124k
- フォーク
- 38k
- 平均マージ
- 4日 2時間
- マージ済み PR(30日)
- 266
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nodejs/node のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 69/100
メンテナーはふだん 1 日以内に返信
-
fs: document readStream.start and readStream.end対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンdoc
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
nodejs/node#67848 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
doc: document the Buffer.prototype.*Slice() methods対応中かも @AyushCipher が今日担当しました。 オープンdoc
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
nodejs/node#67847 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
`styleText` fast path bypasses `options` and `options.validateStream` validation対応中かも @GBra-4-669 が 8 日前に担当しました。 オープンutil
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
riscv64
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
nodejs/node#67655 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
bug triage needed
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
resource-submission validation-passed
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
hesreallyhim/awesome-claude-code#3773 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
tabatkins/railroad-diagrams#129 ·
-
web: api() turns a null or object-valued error body into a TypeError or "[object Object]" and loses the status対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信