Subject: bin/32785: [dM] du not terabyte-clean
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: netbsd-bugs
Date: 02/09/2006 17:15:00
>Number:         32785
>Category:       bin
>Synopsis:       [dM] du not terabyte-clean
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 09 17:15:00 +0000 2006
>Originator:     der Mouse
>Release:        NetBSD 3.0
>Organization:
	Dis-
>Environment:
System: NetBSD backup.openface.ca 3.0 NetBSD 3.0 (GENERIC) #0: Mon Dec 19 01:04:02 UTC 2005 builds@works.netbsd.org:/home/builds/ab/netbsd-3-0-RELEASE/i386/200512182024Z-obj/home/builds/ab/netbsd-3-0-RELEASE/src/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
	du appears to use a 32-bit signed value for counting blocks of
	space used, with all the overflow implications that go with it.
	For example, in an Amanda virtual-tape directory ($BLOCKSIZE is
	1024):

	% du
	27903503	./slot1
	32211368	./slot2
	32508128	./slot3
	29795873	./slot4
	29999184	./slot5
	30944280	./slot6
	32377384	./slot7
	102091381	./slot8
	50493621	./slot9
	67	./slot10
	67	./slot11
	67	./slot12
	67	./slot13
	67	./slot14
	67	./slot15
	67	./slot16
	67	./slot17
	67	./slot18
	67	./slot19
	67	./slot20
	67	./slot21
	67	./slot22
	67	./slot23
	67	./slot24
	67	./slot25
	67	./slot26
	67	./slot27
	67	./slot28
	28457183	./slot29
	976904009	./2005-12
	-773796458	.

	Note the negative total at the end.  The actual sum of the
	listed numbers is 1373687187, corresponding to 2747374374
	DEV_BSIZE blocks.  This last number is large enough to overflow
	signed-32-bit; it turns into -1547592922, which, divided by two
	($BLOCKSIZE/DEV_BSIZE) is -773796461, almost exactly the
	printed total.  (In the example above, . contains nothing but
	one symlink aside from its subdirs.)
>How-To-Repeat:
	Run du on a directory containing enough stuff, is my best guess.
>Fix:
	None yet.  I'm working on one; I'll have gnats append to this
	PR if/when I have a patch.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B