From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1001 invoked by alias); 20 Sep 2009 16:57:23 -0000 Received: (qmail 963 invoked by uid 48); 20 Sep 2009 16:57:12 -0000 Date: Sun, 20 Sep 2009 16:57:00 -0000 Message-ID: <20090920165712.962.qmail@sourceware.org> From: "andersk at ksplice dot com" To: glibc-bugs@sources.redhat.com In-Reply-To: <20090920165230.10672.andersk@ksplice.com> References: <20090920165230.10672.andersk@ksplice.com> Reply-To: sourceware-bugzilla@sourceware.org Subject: [Bug libc/10672] qsort may not be a stable sort under memory exhaustion X-Bugzilla-Reason: CC Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org X-SW-Source: 2009-09/txt/msg00051.txt.bz2 ------- Additional Comments From andersk at ksplice dot com 2009-09-20 16:57 ------- Created an attachment (id=4219) --> (http://sourceware.org/bugzilla/attachment.cgi?id=4219&action=view) Test program This program exhausts all the available heap memory using malloc(), then attempts to do a stable sort using qsort() as described by the glibc manual. As you can see from the output, some items with equal values have been reordered: … 0 0 0 0 10 4 10 2 10 3 20 1 If you comment the malloc() exhaustion loop, the sort becomes stable: … 0 0 0 0 10 2 10 3 10 4 20 1 -- http://sourceware.org/bugzilla/show_bug.cgi?id=10672 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.