This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/10672] qsort may not be a stable sort under memory exhaustion


------- 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]