Skip to content

Fix: memory leak and silent read error in Archiver._compressFile causing build failures under /Users/ - #1432

Merged
jglogan merged 1 commit into
apple:mainfrom
Ronitsabhaya75:bug-container-build-fails
Apr 22, 2026
Merged

Fix: memory leak and silent read error in Archiver._compressFile causing build failures under /Users/#1432
jglogan merged 1 commit into
apple:mainfrom
Ronitsabhaya75:bug-container-build-fails

Conversation

@Ronitsabhaya75

@Ronitsabhaya75 Ronitsabhaya75 commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Motivation and Context

fixes : #1423

_compressFile() allocated a 1 MiB read buffer per file but never freed it, leaking ~20 GiB with large contexts (~20k files). It also treated InputStream.read() errors (-1) the same as EOF (0), silently swallowing TCC access denials under /Users/ and corrupting the archive state — which surfaced as the unhelpful "unable to write data to the archive, code 0" error.

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

@Ronitsabhaya75
Ronitsabhaya75 marked this pull request as ready for review April 20, 2026 02:51

@jglogan jglogan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @Ronitsabhaya75, good catch!

@jglogan
jglogan merged commit 2e029c8 into apple:main Apr 22, 2026
4 checks passed
@Ronitsabhaya75
Ronitsabhaya75 deleted the bug-container-build-fails branch May 20, 2026 01:54
jianliang00 pushed a commit to jianliang00/container that referenced this pull request Aug 28, 2026
…ing build failures under /Users/ (apple#1432)

- Closes apple#1439.
- May also address some cases of apple#1423.
- `_compressFile()` allocated a 1 MiB read buffer
  per file but never freed it.
- It also treated InputStream.read() errors (-1) the
  same as EOF (0), silently swallowing errors such
  as TCC access denials under /Users/, which could
  result in unexpected archive contents.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants