From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/9111 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Possible infinite loop in qsort() Date: Thu, 14 Jan 2016 17:17:11 -0500 Message-ID: <20160114221711.GT238@brightrain.aerifal.cx> References: <20160109082139.GD2016@debian> <20160109090719.GA385@nyan> <20160110040516.GQ238@brightrain.aerifal.cx> <20160110113852.GE2016@debian> <5694F0D5.8080709@openwall.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1452809857 3541 80.91.229.3 (14 Jan 2016 22:17:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 14 Jan 2016 22:17:37 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-9124-gllmg-musl=m.gmane.org@lists.openwall.com Thu Jan 14 23:17:29 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1aJqCu-0002RK-Ab for gllmg-musl@m.gmane.org; Thu, 14 Jan 2016 23:17:28 +0100 Original-Received: (qmail 3561 invoked by uid 550); 14 Jan 2016 22:17:24 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 3542 invoked from network); 14 Jan 2016 22:17:23 -0000 Content-Disposition: inline In-Reply-To: <5694F0D5.8080709@openwall.com> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:9111 Archived-At: On Tue, Jan 12, 2016 at 03:25:57PM +0300, Alexander Cherepanov wrote: > On 2016-01-10 14:38, Markus Wichmann wrote: > >On Sat, Jan 09, 2016 at 11:05:16PM -0500, Rich Felker wrote: > >>On Sat, Jan 09, 2016 at 10:07:19AM +0100, Felix Janda wrote: > >>>musl enforces that object sizes should not be greater than PTRDIFF_MAX. > >>>See for example the discussion at > >>> > >>>http://www.openwall.com/lists/musl/2013/06/27/7 > >>> > >>>So there will not be objects of size 3GB with musl on x32. Since the > >>>Leonardo numbers grow slower than 2^n in general no overflow should > >>>happen if "size" is valid. Otherwise, UB was invoked. > >> > > > >OK. Might want to make that assumption a bit more prominent, because > >this is the first time I've ever heard about it, but OK, no objects >2GB > >on 32-bit archs. > > Yeah, I don't see it in the doc. Did I miss it? The documentation is incomplete; in particular, the part that would cover things like this has not been written at all and exists just in my head (and to a lesser extent as implied from commit messages and mailing list threads). :-) > If it neither works nor documented as a limit I'd call it a bug. An implementation is under no obligation to document the conditions under which it's "out of memory" (ENOMEM). These are usually complex and highly implementation specific. > BTW the support in compilers for working with objects larger than > half the address space is buggy -- see > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67999 . The same > situation -- it neither works nor documented. Somewhat puzzling... The only bug here is that it's not documented. "Supporting" such objects without making ptrdiff_t a 64-bit type is an intolerably bad QoI issue. Rich