From 2c02a9547669f95d3b44c3e7c39e7e3d0946fa17 Mon Sep 17 00:00:00 2001 From: ASDAlexander77 Date: Mon, 5 Oct 2026 18:55:34 +0100 Subject: [PATCH] Android: build the collector without parallel marking With parallel marking, several threads allocating at once deadlocked the collector during marking on an Android API 29 x86_64 emulator: the collecting thread waits in GC_do_parallel_mark for the markers, two markers block re-acquiring mark_mutex, every other thread is in the suspend handler. A plain C program reproduces it (bdwgc 8.2.12: 5 hangs in 12 runs, master: 2 in 12; GC_MARKERS=1: none), reported upstream as https://github.com/bdwgc/bdwgc/issues/980. Marking now runs on the collecting thread alone. Co-Authored-By: Claude Opus 5.5 --- scripts/build_gc_release_android.bat | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/build_gc_release_android.bat b/scripts/build_gc_release_android.bat index db9ce3621..5b5cf3247 100644 --- a/scripts/build_gc_release_android.bat +++ b/scripts/build_gc_release_android.bat @@ -5,6 +5,11 @@ @rem Needs the Android NDK (tested with r30) in ANDROID_NDK_HOME, and Ninja. Installs into @rem 3rdParty\gc\android\\release. API level 29 is the floor the default library needs @rem (timespec_get). +@rem +@rem Parallel marking is off: with it, several threads allocating at once deadlocked the +@rem collector during marking on an API 29 x86_64 emulator (bdwgc 8.2.12 and master; reported +@rem upstream as https://github.com/bdwgc/bdwgc/issues/980). Marking then runs on the collecting +@rem thread alone. @echo off setlocal @@ -32,6 +37,6 @@ cmake -S "%ROOT%\3rdParty\gc-8.2.12" -B "%BUILD_DIR%" -G Ninja -Wno-dev ^ -DANDROID_ABI=%ABI% -DANDROID_PLATFORM=android-29 ^ -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON ^ -DCMAKE_INSTALL_PREFIX="%ROOT%\3rdParty\gc\android\%ABI%\release" ^ - -Denable_threads=ON -Denable_cplusplus=OFF -Denable_docs=OFF -Dbuild_tests=OFF -Dbuild_cord=OFF || exit /b 1 + -Denable_threads=ON -Denable_parallel_mark=OFF -Denable_cplusplus=OFF -Denable_docs=OFF -Dbuild_tests=OFF -Dbuild_cord=OFF || exit /b 1 cmake --build "%BUILD_DIR%" -j 8 || exit /b 1 cmake --install "%BUILD_DIR%" || exit /b 1