From owner-freebsd-bugs Tue Jan 30 6:10:23 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id EF65E37B4E0 for ; Tue, 30 Jan 2001 06:10:04 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.1/8.11.1) id f0UEA4k56894; Tue, 30 Jan 2001 06:10:04 -0800 (PST) (envelope-from gnats) Date: Tue, 30 Jan 2001 06:10:04 -0800 (PST) Message-Id: <200101301410.f0UEA4k56894@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Bruce Evans Subject: Re: bin/24732: cmp can not compare files lager 2GB but smaller 4GB Reply-To: Bruce Evans Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR bin/24732; it has been noted by GNATS. From: Bruce Evans To: kazarov@izmiran.rssi.ru Cc: freebsd-gnats-submit@FreeBSD.ORG Subject: Re: bin/24732: cmp can not compare files lager 2GB but smaller 4GB Date: Wed, 31 Jan 2001 01:02:21 +1100 (EST) On Tue, 30 Jan 2001 kazarov@izmiran.rssi.ru wrote: > And tests shows that cmp cannot mmap two files of silze greate about 1213MB (on my system). This seems about right for i386's. Two files have to be mapped below the kernel start address of 3G, so their size is limited to 1.5GB. Big files, at least, have to be mapped after libraries, so there size is further limited. > So constant should be decreased to 1GB This is rather machine-dependent, and probably too large to be optimal anyway. To fix the machine-dependencies, I think cmp should just try to mmap both files and fall back to c_special() if this fails. Note that the current check against SIZE_T_MAX is just to prevent overflow, but it is broken in several ways: (1) It SIZE_T_MAX with MIN(len1, len2), but it needs to compare with MAX(len1, len2) to prevent overflow when the lengths are cast to size_t. (2) It needs comapare SIZE_T_MAX with MAX(len1 + skip1 % pagesize, len2 + skip2 % pagesize) to prevent overflow when the adjusted lengths are passed to mmap(). The casts in (1) are bogus anyway. They are unnecessary if a prototype for mmap() is in scope and are in the wrong place otherwise (the whole adjusted lengths should be cast). Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message