Brian,
It's difficult to produce a simple test case with erratic behavior. I have
wrapped my qsort invocations within a qqsort routine. I've attached
qqsort.h which includes both the wrapper and the netbad qsort.c renamed as
Qsort (and with _DIAGASSERT's commented out). Also attached is cygsort.txt
which is script output demonstrating the problem. My apologies that is 200+
lines, the Verbose mode states whether Qsort (netbsd) or qsort (cygwin) is
being invoked, I added the '$' command to toggle back and forth. Descending
sorts on the D/C (dpc) column have been most problematic. The descending
'+S dpc' after the ascending '+s dpc' is the most graphic example. I did
publish uac19 v3.3 on SourceForge this morning, or I can send somebody a
tgz.

Corinna,
I'm a cygwin user and neither a cygwin nor netbsd developer. I do not know
what newlib or 'git format-patch' are. If I had access to source for
cygwin's qsort  I could probably devise a patch, but it's probably better
for somebody familiar with the tools cygwin uses to do that. The attached
qqsort.h is an easy geek read. That qsort works with Linux/RHEL7 and with
netbsd's version under cygwin should make fixing it straight forward for
somebody in the know.

Regards, Kurt

On Sun, Aug 30, 2020 at 7:55 PM Brian Inglis <
brian.ing...@systematicsw.ab.ca> wrote:

> On 2020-08-30 15:27, Kurt-Karen Carlson-Lougheed via Cygwin wrote:
> > In a small percentage of qsort requests, the results are erratic. Running
> > the same code under Linux (RHEL7) does NOT have this problem. I updated
> my
> > cygwin to current and the problem persists. I copied the latest
> netbsd.org
> > qsort.c and compiled into my code, the problem is resolved with that
> > version of qsort.
> >
> > In researching this issue, there was a post to this list 2015-01-11
> > reporting a
> > 'damaged' qsort. This may still be the same issue. The netbsd version I
> am
> > now using is dated 2017-05-19.
> >
> > My code experiencing this is SourceForge uac19, I'll be posting the
> > corrected version (v3.2) with the netbsd qsort tomorrow after completing
> > validation tests. I would ultimately like to see cygwin's qsort fixed.
>
> As qsort depends on the array object data types and comparison functions,
> please
> post a Simple Test Case, showing at least those types and function(s), and
> the
> faulty output results.
>
> --
> Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
>
> This email may be disturbing to some readers as it contains
> too much technical detail. Reader discretion is advised.
> [Data in IEC units and prefixes, physical quantities in SI.]
> --
> Problem reports:      https://cygwin.com/problems.html
> FAQ:                  https://cygwin.com/faq/
> Documentation:        https://cygwin.com/docs.html
> Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
>
Script started on 2020-08-31 08:54:58-07:00 [TERM="xterm" TTY="/dev/pty1" 
COLUMNS="132" LINES="54"]
kc: uac19 --version
# uac19 v3.3, Package: uac19-v3.3
kc: uac19 -use owid -v # curl today's file
# Report     names:     US WO
Curl: chdir /home/kac/Downloads
# system (curl --insecure -O -# 
https://covid.ourworldindata.org/data/owid-covid-data.csv 2>/dev/null)
Open: /usr/local/etc/Countries:
Open: /usr/local/etc/Co-Remap:
# Days: 245 First=0 Last=245 Columns=1cipdEevl
# uac19  -m 500  -d 50  -i 1  -v
#  -n US,WO
Date   Confirmed Increase    Inc.%  Deaths  Died+ Days na,cou Location
----   --------- --------    -----  ------  ----- ---- ------ --------
08-31   25251334   221484     0.9%  846841  3687+  1.0 WO,WOR World
08-31    5997163    35581     0.6%  183069   290+  1.0 US,USA United States
kc: uac19 -f ~/Downloads/owid-covid-data.csv -x # interactive mode 
Date   Confirmed Increase    Inc.%  Deaths  Died+ Days Location
----   --------- --------    -----  ------  ----- ---- --------
08-31   25251334   221484     0.9%  846841  3687+  1.0 World
08-31    5997163    35581     0.6%  183069   290+  1.0 United States
Options? -n . +c dpc,-inc.,die -pop 1 -pct 1 # adjust columns, minimum 1% 
confirmed
Date   Confirmed Increase  Deaths  D/C% Million Pct.Co Days Location
----   --------- --------  ------  ---- ------- ------ ---- --------
08-31     625056     2505   14028  2.2%    59.2  1.056  1.0 South Africa
08-31      43750      124     877  2.0%     3.0  1.477  1.0 Armenia
08-31     114020      397     919  0.8%     8.6  1.320  1.0 Israel
08-31      51574      183     189  0.4%     1.7  3.045  1.0 Bahrain
08-31      85544      539     677  0.8%     5.1  1.682  1.0 Oman
08-31     118575      168     197  0.2%     2.9  4.128  1.0 Qatar
08-31      84636      412     530  0.6%     4.3  1.987  1.0 Kuwait
08-31    5997163    35581  183069  3.1%   331.0  1.812  1.0 United States
08-31      32848      298     434  1.3%     2.9  1.145  1.0 Puerto Rico
08-31      92065      728    1995  2.2%     4.3  2.139  1.0 Panama
08-31    3862311    16158  120828  3.1%   212.3  1.819  1.0 Brazil
08-31     647166     7731   28788  4.4%    32.9  1.966  1.0 Peru
08-31     607938     8024   19364  3.2%    50.8  1.196  1.0 Colombia
08-31     409974     1965   11244  2.7%    19.1  2.147  1.0 Chile
Options? -V +c -v +S conf # very verbose, sort confirme descending
# ChkSort 04 0,0,1 c Confirmed 1
# Days: 245 First=0 Last=245 Columns=1cidWmYel
# uac19  -m 500  -d 50  -P  1.0  -Y  1.0  -i 1  +S Confirmed  -V  -x
Date   Confirmed Increase  Deaths  D/C% Million Pct.Co Days Location
----   --------- --------  ------  ---- ------- ------ ---- --------
# Qsort:Confirmed
# l_sort:0:
08-31    5997163    35581  183069  3.1%   331.0  1.812  1.0 United States
08-31    3862311    16158  120828  3.1%   212.3  1.819  1.0 Brazil
08-31     647166     7731   28788  4.4%    32.9  1.966  1.0 Peru
08-31     625056     2505   14028  2.2%    59.2  1.056  1.0 South Africa
08-31     607938     8024   19364  3.2%    50.8  1.196  1.0 Colombia
08-31     409974     1965   11244  2.7%    19.1  2.147  1.0 Chile
08-31     118575      168     197  0.2%     2.9  4.128  1.0 Qatar
08-31     114020      397     919  0.8%     8.6  1.320  1.0 Israel
08-31      92065      728    1995  2.2%     4.3  2.139  1.0 Panama
08-31      85544      539     677  0.8%     5.1  1.682  1.0 Oman
08-31      84636      412     530  0.6%     4.3  1.987  1.0 Kuwait
08-31      51574      183     189  0.4%     1.7  3.045  1.0 Bahrain
08-31      43750      124     877  2.0%     3.0  1.477  1.0 Armenia
08-31      32848      298     434  1.3%     2.9  1.145  1.0 Puerto Rico
# Displayed 14
Options? +S dpc # sort d/c descending
# ChkSort 12 0,0,1 W D/C% 1
# ChkSort 13 0,0,1 W DpC 1
# Days: 245 First=0 Last=245 Columns=1cidWmYel
# uac19  -m 500  -d 50  -P  1.0  -Y  1.0  -i 1  +S D/C%  -V  -x
Date   Confirmed Increase  Deaths  D/C% Million Pct.Co Days Location
----   --------- --------  ------  ---- ------- ------ ---- --------
# Qsort:D/C%
# lDsort:0
08-31     647166     7731   28788  4.4%    32.9  1.966  1.0 Peru
08-31     607938     8024   19364  3.2%    50.8  1.196  1.0 Colombia
08-31    3862311    16158  120828  3.1%   212.3  1.819  1.0 Brazil
08-31    5997163    35581  183069  3.1%   331.0  1.812  1.0 United States
08-31     409974     1965   11244  2.7%    19.1  2.147  1.0 Chile
08-31     625056     2505   14028  2.2%    59.2  1.056  1.0 South Africa
08-31      92065      728    1995  2.2%     4.3  2.139  1.0 Panama
08-31      43750      124     877  2.0%     3.0  1.477  1.0 Armenia
08-31      32848      298     434  1.3%     2.9  1.145  1.0 Puerto Rico
08-31     114020      397     919  0.8%     8.6  1.320  1.0 Israel
08-31      85544      539     677  0.8%     5.1  1.682  1.0 Oman
08-31      84636      412     530  0.6%     4.3  1.987  1.0 Kuwait
08-31      51574      183     189  0.4%     1.7  3.045  1.0 Bahrain
08-31     118575      168     197  0.2%     2.9  4.128  1.0 Qatar
# Displayed 14
Options? $ # toggle netbsd Qsort to cygwin qsort
# Days: 245 First=0 Last=245 Columns=1cidWmYel
# uac19  -m 500  -d 50  -P  1.0  -Y  1.0  -i 1  +S D/C%  -V  -x
Date   Confirmed Increase  Deaths  D/C% Million Pct.Co Days Location
----   --------- --------  ------  ---- ------- ------ ---- --------
# qsort:D/C%
# lDsort:0
08-31     647166     7731   28788  4.4%    32.9  1.966  1.0 Peru
08-31     607938     8024   19364  3.2%    50.8  1.196  1.0 Colombia
08-31    3862311    16158  120828  3.1%   212.3  1.819  1.0 Brazil
08-31    5997163    35581  183069  3.1%   331.0  1.812  1.0 United States
08-31     409974     1965   11244  2.7%    19.1  2.147  1.0 Chile
08-31     625056     2505   14028  2.2%    59.2  1.056  1.0 South Africa
08-31      92065      728    1995  2.2%     4.3  2.139  1.0 Panama
08-31      43750      124     877  2.0%     3.0  1.477  1.0 Armenia
08-31      32848      298     434  1.3%     2.9  1.145  1.0 Puerto Rico
08-31     114020      397     919  0.8%     8.6  1.320  1.0 Israel
08-31      85544      539     677  0.8%     5.1  1.682  1.0 Oman
08-31      84636      412     530  0.6%     4.3  1.987  1.0 Kuwait
08-31      51574      183     189  0.4%     1.7  3.045  1.0 Bahrain
08-31     118575      168     197  0.2%     2.9  4.128  1.0 Qatar
# Displayed 14
Options? +S conf # resort confirmed
# ChkSort 04 0,0,1 c Confirmed 1
# Days: 245 First=0 Last=245 Columns=1cidWmYel
# uac19  -m 500  -d 50  -P  1.0  -Y  1.0  -i 1  +S Confirmed  -V  -x
Date   Confirmed Increase  Deaths  D/C% Million Pct.Co Days Location
----   --------- --------  ------  ---- ------- ------ ---- --------
# qsort:Confirmed
# l_sort:0:
08-31    5997163    35581  183069  3.1%   331.0  1.812  1.0 United States
08-31    3862311    16158  120828  3.1%   212.3  1.819  1.0 Brazil
08-31     647166     7731   28788  4.4%    32.9  1.966  1.0 Peru
08-31     625056     2505   14028  2.2%    59.2  1.056  1.0 South Africa
08-31     607938     8024   19364  3.2%    50.8  1.196  1.0 Colombia
08-31     409974     1965   11244  2.7%    19.1  2.147  1.0 Chile
08-31     118575      168     197  0.2%     2.9  4.128  1.0 Qatar
08-31     114020      397     919  0.8%     8.6  1.320  1.0 Israel
08-31      92065      728    1995  2.2%     4.3  2.139  1.0 Panama
08-31      85544      539     677  0.8%     5.1  1.682  1.0 Oman
08-31      84636      412     530  0.6%     4.3  1.987  1.0 Kuwait
08-31      51574      183     189  0.4%     1.7  3.045  1.0 Bahrain
08-31      43750      124     877  2.0%     3.0  1.477  1.0 Armenia
08-31      32848      298     434  1.3%     2.9  1.145  1.0 Puerto Rico
# Displayed 14
Options? +S dpc # sort d/c again (cygwin qsort)
# ChkSort 12 0,0,1 W D/C% 1
# ChkSort 13 0,0,1 W DpC 1
# Days: 245 First=0 Last=245 Columns=1cidWmYel
# uac19  -m 500  -d 50  -P  1.0  -Y  1.0  -i 1  +S D/C%  -V  -x
Date   Confirmed Increase  Deaths  D/C% Million Pct.Co Days Location
----   --------- --------  ------  ---- ------- ------ ---- --------
# qsort:D/C%
# lDsort:0
08-31     647166     7731   28788  4.4%    32.9  1.966  1.0 Peru
08-31     607938     8024   19364  3.2%    50.8  1.196  1.0 Colombia
08-31    3862311    16158  120828  3.1%   212.3  1.819  1.0 Brazil
08-31     409974     1965   11244  2.7%    19.1  2.147  1.0 Chile
08-31     625056     2505   14028  2.2%    59.2  1.056  1.0 South Africa
08-31    5997163    35581  183069  3.1%   331.0  1.812  1.0 United States
08-31      92065      728    1995  2.2%     4.3  2.139  1.0 Panama
08-31      43750      124     877  2.0%     3.0  1.477  1.0 Armenia
08-31      32848      298     434  1.3%     2.9  1.145  1.0 Puerto Rico
08-31     114020      397     919  0.8%     8.6  1.320  1.0 Israel
08-31      85544      539     677  0.8%     5.1  1.682  1.0 Oman
08-31      84636      412     530  0.6%     4.3  1.987  1.0 Kuwait
08-31      51574      183     189  0.4%     1.7  3.045  1.0 Bahrain
08-31     118575      168     197  0.2%     2.9  4.128  1.0 Qatar
# Displayed 14
Options? # note above not in order
# Days: 245 First=0 Last=245 Columns=1cidWmYel
# uac19  -m 500  -d 50  -P  1.0  -Y  1.0  -i 1  +S D/C%  -V  -x
Options? +s dpc # sort d/c ascending
# ChkSort 12 0,1,0 W D/C% 1
# ChkSort 13 0,1,0 W DpC 1
# Days: 245 First=0 Last=245 Columns=1cidWmYel
# uac19  -m 500  -d 50  -P  1.0  -Y  1.0  -i 1  +s D/C%  -V  -x
Date   Confirmed Increase  Deaths  D/C% Million Pct.Co Days Location
----   --------- --------  ------  ---- ------- ------ ---- --------
# qsort:D/C%
# lDsort:1
08-31     118575      168     197  0.2%     2.9  4.128  1.0 Qatar
08-31      51574      183     189  0.4%     1.7  3.045  1.0 Bahrain
08-31      84636      412     530  0.6%     4.3  1.987  1.0 Kuwait
08-31      85544      539     677  0.8%     5.1  1.682  1.0 Oman
08-31     114020      397     919  0.8%     8.6  1.320  1.0 Israel
08-31      32848      298     434  1.3%     2.9  1.145  1.0 Puerto Rico
08-31      43750      124     877  2.0%     3.0  1.477  1.0 Armenia
08-31      92065      728    1995  2.2%     4.3  2.139  1.0 Panama
08-31     625056     2505   14028  2.2%    59.2  1.056  1.0 South Africa
08-31     409974     1965   11244  2.7%    19.1  2.147  1.0 Chile
08-31    5997163    35581  183069  3.1%   331.0  1.812  1.0 United States
08-31    3862311    16158  120828  3.1%   212.3  1.819  1.0 Brazil
08-31     607938     8024   19364  3.2%    50.8  1.196  1.0 Colombia
08-31     647166     7731   28788  4.4%    32.9  1.966  1.0 Peru
# Displayed 14
Options? +S d/c # sort d/c descending
# ChkSort 12 0,0,1 W D/C% 1
# Days: 245 First=0 Last=245 Columns=1cidWmYel
# uac19  -m 500  -d 50  -P  1.0  -Y  1.0  -i 1  +S D/C%  -V  -x
Date   Confirmed Increase  Deaths  D/C% Million Pct.Co Days Location
----   --------- --------  ------  ---- ------- ------ ---- --------
# qsort:D/C%
# lDsort:0
08-31     118575      168     197  0.2%     2.9  4.128  1.0 Qatar
08-31      51574      183     189  0.4%     1.7  3.045  1.0 Bahrain
08-31      84636      412     530  0.6%     4.3  1.987  1.0 Kuwait
08-31     114020      397     919  0.8%     8.6  1.320  1.0 Israel
08-31      85544      539     677  0.8%     5.1  1.682  1.0 Oman
08-31      32848      298     434  1.3%     2.9  1.145  1.0 Puerto Rico
08-31     647166     7731   28788  4.4%    32.9  1.966  1.0 Peru
08-31     607938     8024   19364  3.2%    50.8  1.196  1.0 Colombia
08-31    3862311    16158  120828  3.1%   212.3  1.819  1.0 Brazil
08-31    5997163    35581  183069  3.1%   331.0  1.812  1.0 United States
08-31     409974     1965   11244  2.7%    19.1  2.147  1.0 Chile
08-31     625056     2505   14028  2.2%    59.2  1.056  1.0 South Africa
08-31      92065      728    1995  2.2%     4.3  2.139  1.0 Panama
08-31      43750      124     877  2.0%     3.0  1.477  1.0 Armenia
# Displayed 14
Options? # that sure didn't work well, did it?
# Days: 245 First=0 Last=245 Columns=1cidWmYel
# uac19  -m 500  -d 50  -P  1.0  -Y  1.0  -i 1  +S D/C%  -V  -x
Options? $ # toggle cyqwin qsort back to netbsd Qsort
# Days: 245 First=0 Last=245 Columns=1cidWmYel
# uac19  -m 500  -d 50  -P  1.0  -Y  1.0  -i 1  +S D/C%  -V  -x
Date   Confirmed Increase  Deaths  D/C% Million Pct.Co Days Location
----   --------- --------  ------  ---- ------- ------ ---- --------
# Qsort:D/C%
# lDsort:0
08-31     647166     7731   28788  4.4%    32.9  1.966  1.0 Peru
08-31     607938     8024   19364  3.2%    50.8  1.196  1.0 Colombia
08-31    3862311    16158  120828  3.1%   212.3  1.819  1.0 Brazil
08-31    5997163    35581  183069  3.1%   331.0  1.812  1.0 United States
08-31     409974     1965   11244  2.7%    19.1  2.147  1.0 Chile
08-31     625056     2505   14028  2.2%    59.2  1.056  1.0 South Africa
08-31      92065      728    1995  2.2%     4.3  2.139  1.0 Panama
08-31      43750      124     877  2.0%     3.0  1.477  1.0 Armenia
08-31      32848      298     434  1.3%     2.9  1.145  1.0 Puerto Rico
08-31     114020      397     919  0.8%     8.6  1.320  1.0 Israel
08-31      85544      539     677  0.8%     5.1  1.682  1.0 Oman
08-31      84636      412     530  0.6%     4.3  1.987  1.0 Kuwait
08-31      51574      183     189  0.4%     1.7  3.045  1.0 Bahrain
08-31     118575      168     197  0.2%     2.9  4.128  1.0 Qatar
# Displayed 14
Options? # all is well with netbsd version
# Days: 245 First=0 Last=245 Columns=1cidWmYel
# uac19  -m 500  -d 50  -P  1.0  -Y  1.0  -i 1  +S D/C%  -V  -x
Options? quit
kc: exit
exit

Script done on 2020-08-31 09:03:46-07:00 [COMMAND_EXIT_CODE="0"]

Attachment: qqsort.h
Description: Binary data

--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to