From 4bd120cf58da4e949ed12627772d9872f2537abb Mon Sep 17 00:00:00 2001 From: Skullian <133133667+Skullians@users.noreply.github.com> Date: Tue, 24 Nov 2026 20:16:18 +0000 Subject: [PATCH] fix: winpthread leaks --- .github/workflows/native-builds.yml | 7 ++++--- README.md | 2 +- jni/build-windows.sh | 17 ++++++++++++----- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/.github/workflows/native-builds.yml b/.github/workflows/native-builds.yml index 6676627..5d6c379 100644 --- a/.github/workflows/native-builds.yml +++ b/.github/workflows/native-builds.yml @@ -55,12 +55,13 @@ jobs: platform: arm64 libc: musl runtime: alpine:3.22 + # see jni/build-windows.sh - classifier: windows-x86_64 family: windows runner: windows-2022 - msystem: MINGW64 - package-prefix: mingw-w64-x86_64 - compiler: gcc + msystem: CLANG64 + package-prefix: mingw-w64-clang-x86_64 + compiler: clang task: compileNativeForWindowsX8664 directory: windows-x86_64 library: libdatachannel-java.dll diff --git a/README.md b/README.md index 1d2999d..3aeac09 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Build one Linux native with, for example: The CI matrix builds all eight Linux, Windows, and macOS targets concurrently on matching x86_64 or ARM64 runners. Only musl uses a container (Alpine 3.22); glibc builds use GCC 12 and OpenSSL from Ubuntu 22.04, Windows builds use native -MSYS2 MINGW64/CLANGARM64 with static OpenSSL, and macOS builds use the host +MSYS2 CLANG64/CLANGARM64 with static OpenSSL, and macOS builds use the host toolchain. Install the corresponding build dependencies for local builds. Every job checks lazy and eager loading of the packaged bundle in a matching diff --git a/jni/build-windows.sh b/jni/build-windows.sh index 6dafb65..6a2a8ec 100644 --- a/jni/build-windows.sh +++ b/jni/build-windows.sh @@ -7,13 +7,20 @@ case "$TARGET_CLASSIFIER:$MSYSTEM" in cxx_compiler=clang++ expected_target=aarch64-w64-windows-gnu ;; - windows-x86_64:MINGW64) - compiler=gcc - cxx_compiler=g++ - expected_target=x86_64-w64-mingw32 + windows-x86_64:CLANG64) + # replaced gcc & libstdc++ with clang & libc++ + # (https://github.com/GeyserMC/Geyser/issues/6920) - libstdc++ seems to be leaking handles on windows... + # apparently its mutex handling doesn't destroy pthreads if a static initializer exists... which is all fine and dandy on linux, + # but windows's handling (dubbed winpthreads), in its infinite wisdom, seems to do shenanigans where events and sempahores aren't freed until destroy + # >> et voila, you get like 50-100 handles leaking every time + # had to hunt these down, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59807 and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107857 both describe this issue + # alas, libc++ on the other hand, doesn't have this issue + compiler=clang + cxx_compiler=clang++ + expected_target=x86_64-w64-windows-gnu ;; *) - echo "Use CLANGARM64 on Windows ARM64 or MINGW64 on Windows x86_64" >&2 + echo "Use CLANGARM64 on Windows ARM64 or CLANG64 on Windows x86_64" >&2 exit 1 ;; esac