From 402ddf1eee87f975226416e9e8a4e04940568798 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 17 Jan 2026 15:56:22 +0100 Subject: [PATCH] sort: on 32 bits, decrease the buf max size See https://bugs.launchpad.net/ubuntu/+source/rust-coreutils/+bug/2137562 --- src/uu/sort/src/sort.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index ddbf225762c..10a37a3c77e 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -123,6 +123,11 @@ const POSITIVE: &u8 = &b'+'; // reasonably large chunks for typical workloads. const MIN_AUTOMATIC_BUF_SIZE: usize = 512 * 1024; // 512 KiB const FALLBACK_AUTOMATIC_BUF_SIZE: usize = 32 * 1024 * 1024; // 32 MiB +// On 32-bit systems, use a smaller max buffer (256 MiB) to avoid allocation +// failures due to limited virtual address space. +#[cfg(target_pointer_width = "32")] +const MAX_AUTOMATIC_BUF_SIZE: usize = 256 * 1024 * 1024; // 256 MiB +#[cfg(not(target_pointer_width = "32"))] const MAX_AUTOMATIC_BUF_SIZE: usize = 1024 * 1024 * 1024; // 1 GiB #[derive(Debug, Error)]