Subject: bin/18614: sort in -current 10/10/2002 (multiple issues)
To: None <>
From: None <>
List: netbsd-bugs
Date: 10/10/2002 23:25:47
>Number:         18614
>Category:       bin
>Synopsis:       sort in -current 10/10/2002 (multiple issues)
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Oct 10 16:26:00 PDT 2002
>Originator:     User explorer
>Release:        NetBSD 1.6I
>Organization:  yes, we do know everything
System: NetBSD 1.6I NetBSD 1.6I (GENERIC.MP) #0: Thu Oct 3 22:57:42 PDT 2002 i386
Architecture: i386
Machine: i386
When running sort on a large file (310,199,825 bytes, 46,701,436 lines)
the default file descriptor limits are not sufficient:

	explorer@here-there-be-dragons> sort -u -o foo fename.txt 
	sort: ftmp: mkstemp("/tmp/sort.003822ch"): Too many open files

Running "unlimit" first, which increases my open file litmit
to 12,560 files, produces:

	explorer@here-there-be-dragons> sort -u -o foo fename.txt
	sort: ftmp: mkstemp("/sort.003824xz"): Permission denied

(Note that the variable "tmpdir" is getting smashed here!)

If I put a "char unused_padding[10240];" line in sort.c, between
toutpath and tmpdir, I no longer get this message.  I then get
the "too many open files" again.

sort is quite clearly using too many of these temporary files.  It should
try to limit how many it uses to something that the system-default value
will allow -- 64 is, last I checked, the system default pretty much everywhere.
If nothing else works, I can provide a file that I used.
None known.