openssl/cygwin crashes when pthread APIs are called in
DllMain:
0 0x0000000000000000 in ?? ()
1 0x00000001801619bd in pthread_rwlock_wrlock (rwlock=0x800275ff0)
at /c/S/msys2-runtime-3.3/src/msys2-runtime/winsup/cygwin/thread.cc:3228
2 0x000000018019905b in _sigfe () at sigfe.s:35
3 0x00000004358490c9 in CRYPTO_THREAD_write_lock () from /usr/bin/msys-crypto-3.dll
4 0x000000043583c414 in init_thread_remove_handlers () from /usr/bin/msys-crypto-3.dll
5 0x000000043583c843 in OPENSSL_thread_stop () from /usr/bin/msys-crypto-3.dll
6 0x000000043583a953 in DllMain () from /usr/bin/msys-crypto-3.dll
It can be reliably reproduced by calling "meson test", which spawns threads for tests.
Something similar was discussed on the cygwin mailing list years ago, and it seems
nothing has changed/improved there, and with openssl v3 it always crashes:
https://cygwin.com/pipermail/cygwin/2011-March/194454.html
Let's do what corinna suggested there, skip OPENSSL_thread_stop() under cygwin.
This is a hacky workaround, but better to leak things then to crash.