Bug: Missing Error Propagation on Deferred target.Close() in copyFile leads to Corrupted Rootfs
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 74/100
Research direction
Open pkg/unikontainers/utils.go and inspect the copyFile helper, starting with its io.Copy call and deferred target.Close(). Trace how errors are returned from the helper, then verify that a close failure is reported instead of being swallowed. Done means copyFile cannot report success when closing the destination file fails.
Written by the indexing model from the issue text.
Description
Describe the bug
In pkg/unikontainers/utils.go, the copyFile helper manages transferring files via io.Copy() and leverages defer target.Close() for the destination file pointer cleanup.
Errors returned by target.Close() are currently silently swallowed. In Go, io.Copy() relies heavily on system-level buffered I/O. When caching runtime configurations or staging guest payloads into tight memory boundaries (e.g., small tmpfs partitions), the actual data flush often happens synchronously during process closure. When flushing fails (e.g. out of memory/disk space limits), target.Close() evaluates to an error. By abandoning this specific error matrix inside the defer, copyFile will erroneously return nil despite staging a truncated or corrupted file, which leads to urunc silently configuring corrupted boot components.
Proposed Solution
Refactor the function exit trajectory to explicitly invoke and validate the file pointer closure:
if err := target.Close(); err != nil {
return fmt.Errorf("failed to sync duplicated file: %w", err)
}
return nil
- Dominant language
- Go
- Stars
- 298
- Forks
- 202
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 28
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from urunc-dev/urunc
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
do-not-merge invalid
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
enhancement needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
kind/cleanup
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
kubernetes-sigs/kueue#15947 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
sympozium-ai/sympozium#627 ·
-
priority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/librarian#7636 ·