Unexpected zero return code from `throw std::runtime_error`
Adam Dinwoodie
adam@dinwoodie.org
Sat Jul 2 13:21:58 GMT 2022
I'm currently experimenting with compiling rdfind for Cygwin, and one of
the testcases is failing because std::runtime_error is expected to
result in the compiled program exiting with a non-zero return code,
but on Cygwin, it just seems to cause the program to terminate with a
zero return code.
I've attached a simple test case. Compare the output on Cygwin...
$ ./test.sh
+ cat
+ g++ test.cc
+ [[ -x a.exe ]]
+ ./a.exe
+ rc=0
+ (( rc == 0 ))
+ echo 'Unexpected zero return code from execution'
Unexpected zero return code from execution
+ exit 1
...with the output from one of my Debian boxes...
$ ./test.sh
+ cat
+ g++ test.cc
+ [[ -x a.exe ]]
+ [[ -x a.out ]]
+ ./a.out
terminate called after throwing an instance of 'std::runtime_error'
what(): Test error
./test.sh: line 21: 566327 Aborted ./a.out
+ rc=134
+ (( rc == 0 ))
+ echo 'Expected non-zero return code received: 134'
Expected non-zero return code received: 134
+ exit 0
I'm not massively familiar with C++, so I could well be missing
something obvious, but this seems like an unexpected difference between
Cygwin and other *nix platforms. Is this a Cygwin bug, or am I doing
something wrong?
cygcheck -srv output attached as well, from a minimal sandbox system I
used to confirm the issue wasn't just my environment.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.sh
Type: application/x-sh
Size: 464 bytes
Desc: not available
URL: <https://cygwin.com/pipermail/cygwin/attachments/20220702/065e2ece/attachment.sh>
-------------- next part --------------
Cygwin Configuration Diagnostics
Current System Time: Sat Jul 02 14:13:30 2022
Windows 11 Enterprise Ver 10.0 Build 22000
Running in Terminal Service session
Path: C:\cygwin64\usr\local\bin
C:\cygwin64\bin
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0
C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps
Output from C:\cygwin64\bin\id.exe
UID: 197112(WDAGUtilityAccount)
GID: 197121(None)
197121(None)
114(Local account and member of Administrators group)
555(Remote Desktop Users)
545(Users)
544(Administrators)
14(REMOTE INTERACTIVE LOGON)
4(INTERACTIVE)
11(Authenticated Users)
15(This Organization)
113(Local account)
4095(CurrentSession)
66048(LOCAL)
262154(NTLM Authentication)
405504(High Mandatory Level)
SysDir: C:\Windows\system32
WinDir: C:\Windows
USER = 'WDAGUtilityAccount'
PWD = '/home/WDAGUtilityAccount'
HOME = '/home/WDAGUtilityAccount'
USERDOMAIN = '6301FE85-AA7E-4'
OS = 'Windows_NT'
COMMONPROGRAMFILES = 'C:\Program Files\Common Files'
PROCESSOR_LEVEL = '6'
PSModulePath = 'C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules'
CommonProgramW6432 = 'C:\Program Files\Common Files'
CommonProgramFiles(x86) = 'C:\Program Files (x86)\Common Files'
TZ = 'Europe/London'
HOSTNAME = '6301fe85-aa7e-4837-8410-6729cbf55da8'
PUBLIC = 'C:\Users\Public'
OLDPWD = '/etc/skel'
USERNAME = 'WDAGUtilityAccount'
LOGONSERVER = '\\6301FE85-AA7E-4'
PROCESSOR_ARCHITECTURE = 'AMD64'
CLIENTNAME = 'efc74034-10d9-4'
LOCALAPPDATA = 'C:\Users\WDAGUtilityAccount\AppData\Local'
COMPUTERNAME = '6301FE85-AA7E-4'
!:: = '::\'
SYSTEMDRIVE = 'C:'
USERPROFILE = 'C:\Users\WDAGUtilityAccount'
PATHEXT = '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC'
SYSTEMROOT = 'C:\Windows'
USERDOMAIN_ROAMINGPROFILE = '6301FE85-AA7E-4'
PROCESSOR_IDENTIFIER = 'Intel64 Family 6 Model 158 Stepping 13, GenuineIntel'
TMP = '/tmp'
LC_CTYPE = 'en_US.UTF-8'
TERM_PROGRAM = 'mintty'
TERM_PROGRAM_VERSION = '3.6.1'
PROCESSOR_REVISION = '9e0d'
PROFILEREAD = 'true'
NUMBER_OF_PROCESSORS = '16'
ProgramW6432 = 'C:\Program Files'
COMSPEC = 'C:\Windows\system32\cmd.exe'
APPDATA = 'C:\Users\WDAGUtilityAccount\AppData\Roaming'
SHELL = '/bin/bash'
TERM = 'xterm'
WINDIR = 'C:\Windows'
ProgramData = 'C:\ProgramData'
SHLVL = '1'
MINTTY_SHORTCUT = '/cygdrive/c/Users/Public/Desktop/Cygwin64 Terminal.lnk'
PROGRAMFILES = 'C:\Program Files'
ALLUSERSPROFILE = 'C:\ProgramData'
TEMP = '/tmp'
DriverData = 'C:\Windows\System32\Drivers\DriverData'
SESSIONNAME = '31C5CE94259D4006A9E4#0'
ProgramFiles(x86) = 'C:\Program Files (x86)'
PS1 = '\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '
HOMEDRIVE = 'C:'
INFOPATH = '/usr/local/info:/usr/share/info:/usr/info'
HOMEPATH = '\Users\WDAGUtilityAccount'
ORIGINAL_PATH = '/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Users/WDAGUtilityAccount/AppData/Local/Microsoft/WindowsApps'
EXECIGNORE = '*.dll'
_ = '/usr/bin/cygcheck'
HKEY_LOCAL_MACHINE\SOFTWARE\Cygwin
HKEY_LOCAL_MACHINE\SOFTWARE\Cygwin\Installations
(default) = '\??\C:\cygwin64'
HKEY_LOCAL_MACHINE\SOFTWARE\Cygwin\setup
(default) = 'C:\cygwin64'
obcaseinsensitive set to 1
Cygwin installations found in the registry:
System: Key: e022582115c10879 Path: C:\cygwin64
c: hd NTFS 40830Mb 9% CP CS UN PA FC
C:\cygwin64 / system binary,auto
C:\cygwin64\bin /usr/bin system binary,auto
C:\cygwin64\lib /usr/lib system binary,auto
cygdrive prefix /cygdrive user binary,posix=0,auto
Found: C:\cygwin64\bin\awk
-> C:\cygwin64\bin\gawk.exe
Found: C:\cygwin64\bin\bash.exe
Found: C:\cygwin64\bin\cat.exe
Found: C:\Windows\system32\certutil.exe
Not Found: clinfo
Found: C:\Windows\system32\comp.exe
Found: C:\Windows\system32\convert.exe
Found: C:\cygwin64\bin\cp.exe
Found: C:\cygwin64\bin\cpp.exe
Not Found: crontab
Found: C:\Windows\system32\curl.exe
Found: C:\cygwin64\bin\expand.exe
Found: C:\Windows\system32\expand.exe
Warning: C:\cygwin64\bin\expand.exe hides C:\Windows\system32\expand.exe
Found: C:\cygwin64\bin\find.exe
Found: C:\Windows\system32\find.exe
Warning: C:\cygwin64\bin\find.exe hides C:\Windows\system32\find.exe
Found: C:\Windows\system32\ftp.exe
Found: C:\cygwin64\bin\gcc.exe
Not Found: gdb
Found: C:\cygwin64\bin\grep.exe
Found: C:\cygwin64\bin\hostname.exe
Found: C:\Windows\system32\hostname.exe
Warning: C:\cygwin64\bin\hostname.exe hides C:\Windows\system32\hostname.exe
Found: C:\cygwin64\bin\kill.exe
Not Found: klist
Found: C:\cygwin64\bin\ld.exe
Found: C:\cygwin64\bin\ls.exe
Not Found: make
Found: C:\cygwin64\bin\mv.exe
Found: C:\Windows\system32\nslookup.exe
Not Found: patch
Not Found: perl
Found: C:\Windows\system32\replace.exe
Found: C:\cygwin64\bin\rm.exe
Found: C:\cygwin64\bin\sed.exe
Found: C:\cygwin64\bin\sh.exe
Found: C:\Windows\system32\shutdown.exe
Found: C:\cygwin64\bin\sort.exe
Found: C:\Windows\system32\sort.exe
Warning: C:\cygwin64\bin\sort.exe hides C:\Windows\system32\sort.exe
Not Found: ssh
Found: C:\cygwin64\bin\tar.exe
Found: C:\Windows\system32\tar.exe
Warning: C:\cygwin64\bin\tar.exe hides C:\Windows\system32\tar.exe
Found: C:\cygwin64\bin\test.exe
Found: C:\cygwin64\bin\timeout.exe
Found: C:\Windows\system32\timeout.exe
Warning: C:\cygwin64\bin\timeout.exe hides C:\Windows\system32\timeout.exe
Found: C:\cygwin64\bin\vi.exe
Not Found: vim
Found: C:\cygwin64\bin\whoami.exe
Found: C:\Windows\system32\whoami.exe
Warning: C:\cygwin64\bin\whoami.exe hides C:\Windows\system32\whoami.exe
39k 2016/09/19 C:\cygwin64\bin\cygargp-0.dll - os=4.0 img=0.0 sys=5.2
"cygargp-0.dll" v0.0 ts=2016-09-19 02:13
29k 2022/05/02 C:\cygwin64\bin\cygatomic-1.dll - os=4.0 img=0.0 sys=5.2
"cygatomic-1.dll" v0.0 ts=2022-05-02 11:55
19k 2018/12/20 C:\cygwin64\bin\cygattr-1.dll - os=4.0 img=0.0 sys=5.2
"cygattr-1.dll" v0.0 ts=2018-12-20 09:48
254k 2020/03/31 C:\cygwin64\bin\cygblkid-1.dll - os=4.0 img=0.0 sys=5.2
"cygblkid-1.dll" v0.0 ts=2020-03-28 06:22
66k 2019/07/21 C:\cygwin64\bin\cygbz2-1.dll - os=4.0 img=0.0 sys=5.2
"cygbz2-1.dll" v0.0 ts=2019-07-22 00:05
699k 2019/08/27 C:\cygwin64\bin\cygc++-1.dll - os=4.0 img=1.0 sys=5.2
"cygc++-1.dll" v0.0 ts=2019-08-27 05:06
162k 2019/08/26 C:\cygwin64\bin\cygc++abi-1.dll - os=4.0 img=1.0 sys=5.2
"cygc++abi-1.dll" v0.0 ts=2019-08-26 22:20
2492k 2022/06/26 C:\cygwin64\bin\cygcrypto-1.1.dll - os=4.0 img=0.0 sys=5.2
"cygcrypto-1.1.dll" v0.0 ts=2022-06-26 15:39
353k 2020/03/31 C:\cygwin64\bin\cygfdisk-1.dll - os=4.0 img=0.0 sys=5.2
"cygfdisk-1.dll" v0.0 ts=2020-03-28 06:23
27k 2015/11/17 C:\cygwin64\bin\cygffi-6.dll - os=4.0 img=0.0 sys=5.2
"cygffi-6.dll" v0.0 ts=2015-11-17 22:14
56k 2019/07/28 C:\cygwin64\bin\cygformw-10.dll - os=4.0 img=0.0 sys=5.2
"cygformw-10.dll" v0.0 ts=2019-07-28 17:33
74k 2022/05/02 C:\cygwin64\bin\cyggcc_s-seh-1.dll - os=4.0 img=0.0 sys=5.2
"cyggcc_s-seh-1.dll" v0.0 ts=2022-05-02 11:29
49k 2019/07/10 C:\cygwin64\bin\cyggdbm-6.dll - os=4.0 img=0.0 sys=5.2
"cyggdbm-6.dll" v0.0 ts=2019-07-10 14:53
582k 2021/08/21 C:\cygwin64\bin\cyggmp-10.dll - os=4.0 img=0.0 sys=5.2
"cyggmp-10.dll" v0.0 ts=2021-08-21 19:11
217k 2022/05/02 C:\cygwin64\bin\cyggomp-1.dll - os=4.0 img=0.0 sys=5.2
"cyggomp-1.dll" v0.0 ts=2022-05-02 11:33
36k 2021/08/31 C:\cygwin64\bin\cyghistory7.dll - os=4.0 img=0.0 sys=5.2
"cyghistory7.dll" v0.0 ts=2021-08-31 07:54
1063k 2022/05/23 C:\cygwin64\bin\cygiconv-2.dll - os=4.0 img=0.0 sys=5.2
"cygiconv-2.dll" v0.0 ts=2022-05-23 12:22
42k 2021/07/29 C:\cygwin64\bin\cygintl-8.dll - os=4.0 img=0.0 sys=5.2
"cygintl-8.dll" v0.0 ts=2021-07-29 03:40
1695k 2021/08/21 C:\cygwin64\bin\cygisl-23.dll - os=4.0 img=0.0 sys=5.2
"cygisl-23.dll" v0.0 ts=2021-08-21 18:50
73k 2017/06/19 C:\cygwin64\bin\cyglz4-1.dll - os=4.0 img=0.0 sys=5.2
"cyglz4-1.dll" v0.0 ts=2017-06-19 15:40
147k 2022/03/06 C:\cygwin64\bin\cyglzma-5.dll - os=4.0 img=0.0 sys=5.2
"cyglzma-5.dll" v0.0 ts=2022-03-06 18:26
157k 2022/01/12 C:\cygwin64\bin\cygmagic-1.dll - os=4.0 img=0.0 sys=5.2
"cygmagic-1.dll" v0.0 ts=2022-01-12 09:43
212k 2022/03/19 C:\cygwin64\bin\cygman-2-10-2.dll - os=4.0 img=0.0 sys=5.2
"cygman-2-10-2.dll" v0.0 ts=2022-03-19 15:41
24k 2022/03/19 C:\cygwin64\bin\cygmandb-2-10-2.dll - os=4.0 img=0.0 sys=5.2
"cygmandb-2-10-2.dll" v0.0 ts=2022-03-19 15:41
28k 2019/07/28 C:\cygwin64\bin\cygmenuw-10.dll - os=4.0 img=0.0 sys=5.2
"cygmenuw-10.dll" v0.0 ts=2019-07-28 17:32
100k 2021/08/21 C:\cygwin64\bin\cygmpc-3.dll - os=4.0 img=0.0 sys=5.2
"cygmpc-3.dll" v0.0 ts=2021-08-21 19:35
2663k 2021/08/21 C:\cygwin64\bin\cygmpfr-6.dll - os=4.0 img=0.0 sys=5.2
"cygmpfr-6.dll" v0.0 ts=2021-08-21 19:01
301k 2019/07/28 C:\cygwin64\bin\cygncursesw-10.dll - os=4.0 img=0.0 sys=5.2
"cygncursesw-10.dll" v0.0 ts=2019-07-28 17:30
1020k 2020/03/27 C:\cygwin64\bin\cygp11-kit-0.dll - os=4.0 img=0.0 sys=5.2
"cygp11-kit-0.dll" v0.0 ts=2020-03-27 22:30
14k 2019/07/28 C:\cygwin64\bin\cygpanelw-10.dll - os=4.0 img=0.0 sys=5.2
"cygpanelw-10.dll" v0.0 ts=2019-07-28 17:32
497k 2021/06/20 C:\cygwin64\bin\cygpcre-1.dll - os=4.0 img=0.0 sys=5.2
"cygpcre-1.dll" v0.0 ts=2021-06-20 12:53
627k 2022/04/30 C:\cygwin64\bin\cygpcre2-8-0.dll - os=4.0 img=0.0 sys=5.2
"cygpcre2-8-0.dll" v0.0 ts=2022-04-30 13:08
42k 2020/12/27 C:\cygwin64\bin\cygpipeline-1.dll - os=4.0 img=0.0 sys=5.2
"cygpipeline-1.dll" v0.0 ts=2020-12-27 14:15
42k 2020/12/31 C:\cygwin64\bin\cygpopt-0.dll - os=4.0 img=0.0 sys=5.2
"cygpopt-0.dll" v0.0 ts=2020-12-31 12:16
355k 2022/05/02 C:\cygwin64\bin\cygquadmath-0.dll - os=4.0 img=0.0 sys=5.2
"cygquadmath-0.dll" v0.0 ts=2022-05-02 11:56
254k 2021/08/31 C:\cygwin64\bin\cygreadline7.dll - os=4.0 img=0.0 sys=5.2
"cygreadline7.dll" v0.0 ts=2021-08-31 07:54
11k 2015/07/17 C:\cygwin64\bin\cygsigsegv-2.dll - os=4.0 img=0.0 sys=5.2
"cygsigsegv-2.dll" v0.0 ts=2015-07-17 22:35
156k 2020/03/31 C:\cygwin64\bin\cygsmartcols-1.dll - os=4.0 img=0.0 sys=5.2
"cygsmartcols-1.dll" v0.0 ts=2020-03-28 06:22
512k 2022/06/26 C:\cygwin64\bin\cygssl-1.1.dll - os=4.0 img=0.0 sys=5.2
"cygssl-1.1.dll" v0.0 ts=2022-06-26 15:39
1870k 2022/05/02 C:\cygwin64\bin\cygstdc++-6.dll - os=4.0 img=0.0 sys=5.2
"cygstdc++-6.dll" v0.0 ts=2022-05-02 11:43
68k 2019/07/29 C:\cygwin64\bin\cygtasn1-6.dll - os=4.0 img=0.0 sys=5.2
"cygtasn1-6.dll" v0.0 ts=2019-07-29 03:12
57k 2019/07/28 C:\cygwin64\bin\cygticw-10.dll - os=4.0 img=0.0 sys=5.2
"cygticw-10.dll" v0.0 ts=2019-07-28 17:31
18k 2019/07/22 C:\cygwin64\bin\cygunwind-1.dll - os=4.0 img=1.0 sys=5.2
"cygunwind-1.dll" v0.0 ts=2019-07-22 14:19
27k 2020/03/31 C:\cygwin64\bin\cyguuid-1.dll - os=4.0 img=0.0 sys=5.2
"cyguuid-1.dll" v0.0 ts=2020-03-28 06:22
88k 2022/04/10 C:\cygwin64\bin\cygz.dll - os=4.0 img=0.0 sys=5.2
"cygz.dll" v0.0 ts=2022-04-10 20:26
624k 2022/01/22 C:\cygwin64\bin\cygzstd-1.dll - os=4.0 img=0.0 sys=5.2
"cygzstd-1.dll" v0.0 ts=2022-01-22 17:21
3486k 2022/05/13 C:\cygwin64\bin\cygwin1.dll - os=4.0 img=0.0 sys=5.2
"cygwin1.dll" v0.0 ts=2022-05-13 13:27
Cygwin DLL version info:
DLL version: 3.3.5
DLL epoch: 19
DLL old termios: 5
DLL malloc env: 28
Cygwin conv: 181
API major: 0
API minor: 341
Shared data: 5
DLL identifier: cygwin1
Mount registry: 3
Cygwin registry name: Cygwin
Installations name: Installations
Cygdrive default prefix:
Build date:
Shared id: cygwin1S5
Can't find the cygrunsrv utility, skipping services check.
Cygwin Package Information
Last downloaded files to: C:\Users\WDAGUtilityAccount\Downloads
Last downloaded files from: https://www.mirrorservice.org/sites/sourceware.org/pub/cygwin/
Package Version Status
_autorebase 001091-1 OK
alternatives 1.3.30c-10 OK
base-cygwin 3.8-1 OK
base-files 4.3-3 OK
bash 4.4.12-3 OK
binutils 2.38-1 OK
bzip2 1.0.8-1 OK
ca-certificates 2021.2.52-1 OK
coreutils 8.32-1 OK
crypto-policies 20190218-1 OK
cygutils 1.4.17-1 OK
cygwin 3.3.5-1 OK
cygwin-devel 3.3.5-1 OK
dash 0.5.11.5-1 OK
diffutils 3.8-1 OK
editrights 1.03-1 OK
file 5.41-2 OK
findutils 4.9.0-1 OK
gawk 5.1.1-1 OK
gcc-core 11.3.0-1 OK
gcc-g++ 11.3.0-1 OK
getent 2.18.90-4 OK
grep 3.7-2 OK
groff 1.22.4-1 OK
gzip 1.12-1 OK
hostname 3.13-1 OK
info 6.8-2 OK
ipc-utils 1.0-2 OK
less 590-1 OK
libargp 20110921-3 OK
libatomic1 11.3.0-1 OK
libattr1 2.4.48-2 OK
libblkid1 2.33.1-2 OK
libbz2_1 1.0.8-1 OK
libc++-devel 8.0.1-1 OK
libc++1 8.0.1-1 OK
libc++abi-devel 8.0.1-1 OK
libc++abi1 8.0.1-1 OK
libfdisk1 2.33.1-2 OK
libffi6 3.2.1-2 OK
libgcc1 11.3.0-1 OK
libgdbm6 1.18.1-1 OK
libgmp10 6.2.1-2 OK
libgomp1 11.3.0-1 OK
libiconv2 1.17-1 OK
libintl8 0.21-1 OK
libisl23 0.24-2 OK
liblz4_1 1.7.5-1 OK
liblzma5 5.2.5-1 OK
libmpc3 1.2.1-2 OK
libmpfr6 4.1.0-2 OK
libncursesw10 6.1-1.20190727 OK
libp11-kit0 0.23.20-1 OK
libpcre1 8.45-1 OK
libpcre2_8_0 10.40-1 OK
libpipeline1 1.5.3-1 OK
libpopt-common 1.18-1 OK
libpopt0 1.18-1 OK
libquadmath0 11.3.0-1 OK
libreadline7 8.1-2 OK
libsigsegv2 2.10-2 OK
libsmartcols1 2.33.1-2 OK
libssl1.1 1.1.1p-1 OK
libstdc++6 11.3.0-1 OK
libtasn1_6 4.14-1 OK
libunwind1 8.0.1-1 OK
libuuid1 2.33.1-2 OK
libzstd1 1.5.2-1 OK
login 1.13-1 OK
man-db 2.10.2-1 OK
mintty 3.6.1-1 OK
ncurses 6.1-1.20190727 OK
openssl 1.1.1p-1 OK
p11-kit 0.23.20-1 OK
p11-kit-trust 0.23.20-1 OK
rebase 4.5.0-1 OK
run 1.3.4-2 OK
sed 4.8-1 OK
tar 1.34-1 OK
terminfo 6.1-1.20190727 OK
terminfo-extra 6.1-1.20190727 OK
tzcode 2022a-1 OK
tzdata 2022a-1 OK
util-linux 2.33.1-2 OK
vim-minimal 8.2.4372-1 OK
w32api-headers 10.0.0-1 OK
w32api-runtime 10.0.0-1 OK
which 2.20-2 OK
windows-default-manifest 6.4-1 OK
xz 5.2.5-1 OK
zlib0 1.2.12-1 OK
zstd 1.5.2-1 OK
Use -h to see help about each section
More information about the Cygwin
mailing list