From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/9098 Path: news.gmane.org!not-for-mail From: Alexander Cherepanov Newsgroups: gmane.linux.lib.musl.general Subject: Re: Possible infinite loop in qsort() Date: Tue, 12 Jan 2016 17:31:31 +0300 Message-ID: <56950E43.60508@openwall.com> References: <20160109082139.GD2016@debian> <20160109090719.GA385@nyan> <20160110040516.GQ238@brightrain.aerifal.cx> <20160110113852.GE2016@debian> <5694F0D5.8080709@openwall.com> <20160112124855.GB13558@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1452609120 27304 80.91.229.3 (12 Jan 2016 14:32:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 12 Jan 2016 14:32:00 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-9111-gllmg-musl=m.gmane.org@lists.openwall.com Tue Jan 12 15:31:46 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 1aIzz8-0005di-FT for gllmg-musl@m.gmane.org; Tue, 12 Jan 2016 15:31:46 +0100 Original-Received: (qmail 21642 invoked by uid 550); 12 Jan 2016 14:31:44 -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 21622 invoked from network); 12 Jan 2016 14:31:43 -0000 X-Enigmail-Draft-Status: N1110 In-Reply-To: <20160112124855.GB13558@port70.net> Xref: news.gmane.org gmane.linux.lib.musl.general:9098 Archived-At: On 2016-01-12 15:48, Szabolcs Nagy wrote: > * Alexander Cherepanov [2016-01-12 15:25:57 +0300]: > >> 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? >> >> If it neither works nor documented as a limit I'd call it a bug. > > in musl things are documented in the git log for now, e.g.: > http://git.musl-libc.org/cgit/musl/commit/?id=3cd6f5229f079f892411e82fce3fe15c78eef4d8 IMHO such things should be documented in user-facing documentation, not in source code comments, git log or email posts. > i think if an implementation does not give this guarantee > that should be considered a bug. Some consider it a bug, others -- a feature. But if you want to provide this guarantee it's not that easy. Compilers are not under your control. Even with gcc (which tries to provide this guarantee) you can create VLA 2.5GB in size and run it with `ulimit -s unlimited` (at least as a 32-bit binary on a 64-bit host). Then, a user can create an object of any size via mmap with MAP_FIXED flag, right? > (glibc does not guarantee this and indeed it is full of invalid > pointer arithmetics, Care to provide examples? > but more importantly a huge number of > existing libraries depend on this) > >> 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... > > yes, but it's not possible to support reasonably Why is that? -- Alexander Cherepanov