Skip to content

Drain tar stderr while streaming archives - #800

Closed
antlassagne wants to merge 1 commit into
ximion:mainfrom
antlassagne:797-stderr-bug
Closed

antlassagne wants to merge 1 commit into
ximion:mainfrom
antlassagne:797-stderr-bug

Conversation

@antlassagne

Copy link
Copy Markdown

Drain tar's stderr concurrently while writing archive data to its stdin. Otherwise, diagnostics can fill the stderr pipe and deadlock both processes. Drain stderr to EOF, retaining its first 4096 bytes for error reporting, and join the drain thread before releasing the subprocess.

I used AI to assist me writing this patch

Drain tar's stderr concurrently while writing archive data to its stdin.
Otherwise, diagnostics can fill the stderr pipe and deadlock both processes.
Drain stderr to EOF, retaining its first 4096 bytes for error reporting, and
join the drain thread before releasing the subprocess.
@antlassagne

Copy link
Copy Markdown
Author

Fix: #797

@antlassagne

Copy link
Copy Markdown
Author

@ximion I tested this patch with the reproducer provided by @ogayot in the issue. It hangs without it, and passes with it. Can you review?

@ximion

ximion commented Oct 23, 2026

Copy link
Copy Markdown
Owner

I don't think this is the right solution, creating an entire thread to read a pipe is like pushing a stamp onto a letter with a cannon shot: It kinda works, but is way too much!

I'll have a look at this, my first idea is to just send it to a memfd and limit its size (so a hostile tarball can't exhaust all memory).

@ximion

ximion commented Oct 23, 2026

Copy link
Copy Markdown
Owner

I resolved this with a memfd to catch the output (and a tempfile on systems which don't have memfds) via 6ed4e61

Please test it and see if that resolves the issue for you, and thank you for the patch! :-)

@ximion ximion closed this Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants