This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/10672] qsort may not be a stable sort under memory exhaustion
- From: "andersk at ksplice dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 20 Sep 2009 16:57:12 -0000
- Subject: [Bug libc/10672] qsort may not be a stable sort under memory exhaustion
- References: <20090920165230.10672.andersk@ksplice.com>
- Reply-to: sourceware-bugzilla at sourceware dot org
------- 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.