Bug 25895 - sort in textutils-2.0.11-2 is broken
sort in textutils-2.0.11-2 is broken
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: textutils (Show other bugs)
7.1
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Tim Waugh
David Lawrence
Florence RC-1
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-02-03 16:27 EST by Red Hat Bugzilla
Modified: 2008-03-13 15:18 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-02-06 17:11:44 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Red Hat Bugzilla 2001-02-03 16:27:56 EST
# echo foo | sort 
sort: memory exhausted
Comment 1 Red Hat Bugzilla 2001-02-03 16:33:30 EST
I can't reproduce this on any machine.
Are you sure it's not just what it says, out of memory?
Comment 2 Red Hat Bugzilla 2001-02-03 17:16:00 EST
It turns out that the bug is the usage of

sysconf (_SC_AVPHYS_PAGES);

which returns a number which may not be available to a single
process on a 32bit system with 4GB RAM. In my case, 
it returns 3.8GB. It is the total free memory on my machine.
But it is the usable memory for a single process.
Comment 3 Red Hat Bugzilla 2001-02-03 17:41:05 EST
I am using a patch like this. It seems to work on my 4GB machine.


--- textutils-2.0.11/src/sort.c.mem     Sat Feb  3 13:31:56 2001
+++ textutils-2.0.11/src/sort.c Sat Feb  3 13:35:59 2001
@@ -630,7 +630,9 @@ default_sort_size (void)
 {
   /* Set sortalloc to 50% of available memory, unless it overflows.  */
   double mem = physmem_available ();
-  sortalloc = min (mem, SIZE_MAX);
+  /* Roughly, we may not use more than 1/3 of the adddress space in
+     a single process on Linux even if more memory is available.  */
+  sortalloc = min (mem, SIZE_MAX / 3);
   sortalloc >>= 1;
 
   if (sortalloc < SORTALLOC_DEFAULT_MIN)
Comment 4 Red Hat Bugzilla 2001-02-05 17:58:11 EST
This defect is considered MUST-FIX for Florence Release-Candidate #1
Comment 5 Red Hat Bugzilla 2001-02-06 18:18:35 EST
Should be fixed in textutils-2.0.11-4.  Thanks for the patch!

Note You need to log in before you can comment on or make changes to this bug.