damaged version of qsort.c in the Cygwin library

Corinna Vinschen corinna-cygwin@cygwin.com
Mon Jan 12 12:44:00 GMT 2015

On Jan 11 15:54, ddcc wrote:
> Here what I have send to M. Douglas McIlroy  ::::::

Who's Douglas McIlroy?

> The Cygwin library has a copy of qsort, which you published with Bentley
> around 1993.

Who's Bentley?  Cygwin didn't even exists at all in 1993 and Cygwin has no
own version of qsort.  Rather, it uses the qsort implementation of Newlib.

Newlib introduced qsort in 1992, but that version got replaced with the
qsort implementation from NetBSD in 1995.

> [...]
> The code had been damaged by an "improvement" that invokes sometimes
> insertionsort (not only at the begining), which causes quadratic

Nothing at all was changed in the source code between the introduction of
the NetBSD code in 1995 and 2014, when...

> blow ups.  I reported the problem to a 'volunteer', likely an employee
> of RedHat.  It turns out that now, years later the damaged version is
> still in the Cygwin library.  You can find it at:
>   https://sourceware.org/viewvc/src/newlib/libc/search/qsort.c?revision=1.2&view=markup
> See the variable swap_cnt and the associated code for the damage.
> I am NOT reporting the problem again (due to the way I was harassed
> when I reported the defect) and leave it to you to take action.

[Whatever that means]

> See below for my fixed version.
> I removed swap_cnt and the associated code.
> I have also ordered the actions on the two partitions to minimize
> stack space.
> The second recursive call has been replaced.
> The Cygwin version has other undocumented changes involving a
> procedure qsort_r for which I have no appetite to even think about
> it; software engineering at its worst.

...when Yaakov was so friendly to add the reentrant versions of qsort
called qsort_r, which exist on BSD and GNU systems, but which you seem
to have missed for some reason.

If you have anything constructive to say, please follow up with a patch
on the newlib mailing list newlib AT sourceware DOT org.  While you're
at it, maybe you could condescend to explain what the problem exactly is
and why your solution is better.


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20150112/edce175e/attachment.sig>

More information about the Cygwin mailing list