Skip to content

Apply --memory to .xz and .lzma decompression - #4903

Merged
Cyan4973 merged 1 commit into
devfrom
cli-lzma-memlimit
Nov 7, 2026
Merged

Cyan4973 merged 1 commit into
devfrom
cli-lzma-memlimit

Conversation

@Cyan4973

@Cyan4973 Cyan4973 commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

--memory (128 MiB by default) limits the memory used to decompress zstd frames, but it has never applied to .xz and .lzma input: liblzma was initialized without a limit.

This PR passes the limit to liblzma as well. When a file needs more, zstd reports how much memory it needs and suggests a --memory= value, as it already does for zstd frames:

$ zstd -d --memory=1MB big.xz
big.xz : Memory needed by xz/lzma decoder larger than maximum : 67174448 > 1048576
big.xz : Use --memory=65MB

Behavior change: .xz and .lzma files that need more than 128 MiB to decode now require --memory=, like zstd frames with a large window. Files made with the xz presets are not affected: the largest preset (-9, -9e) uses a 64 MiB dictionary and needs 65 MiB to decode.

The man page now says that --memory also applies to .xz and .lzma.

Tests

  • New in playTests.sh: .xz and .lzma files with a 4 MiB dictionary are rejected with --memory=1MB. The message suggests --memory=5MB, and that value is then accepted.
  • In CI, these tests run in the "CMake build using make wrapper" job, which builds with liblzma.
  • Locally, with liblzma: the full playTests.sh and the cli-tests pass. The build also passes with gcc and clang (-Werror) and without liblzma.

@meta-cla meta-cla Bot added the CLA Signed label Nov 7, 2026
@Cyan4973 Cyan4973 self-assigned this Nov 7, 2026
--memory (128 MiB by default) only limited the decompression of zstd
frames: liblzma was initialized without any limit. Pass it to liblzma
as well. When a file needs more, report how much memory it needs and
suggest a --memory= value, as for zstd frames.

.xz and .lzma files that need more than 128 MiB to decode now require
--memory=, like zstd frames with a large window.
@Cyan4973
Cyan4973 merged commit 5633b0e into dev Nov 7, 2026
110 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant