Bug 25895 - sort in textutils-2.0.11-2 is broken
Summary: sort in textutils-2.0.11-2 is broken
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: textutils
Version: 7.1
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Tim Waugh
QA Contact: David Lawrence
URL:
Whiteboard: Florence RC-1
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-02-03 21:27 UTC by Red Hat Bugzilla
Modified: 2008-03-13 19:18 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2001-02-06 22:11:44 UTC
Embargoed:


Attachments (Terms of Use)

Description Red Hat Bugzilla 2001-02-03 21:27:56 UTC
# echo foo | sort 
sort: memory exhausted

Comment 1 Red Hat Bugzilla 2001-02-03 21:33:30 UTC
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 22:16:00 UTC
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 22:41:05 UTC
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 22:58:11 UTC
This defect is considered MUST-FIX for Florence Release-Candidate #1

Comment 5 Red Hat Bugzilla 2001-02-06 23:18:35 UTC
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.