Skip to content

Android: build the collector without parallel marking - #518

Merged
ASDAlexander77 merged 1 commit into
mainfrom
android-gc-no-parallel-mark
Oct 5, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
android-gc-no-parallel-mark

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

What

scripts/build_gc_release_android.bat now builds Boehm with -Denable_parallel_mark=OFF.

Why

With parallel marking, several threads allocating at once deadlock the collector during marking on an Android API 29 x86_64 emulator:

  • the collecting thread waits in GC_do_parallel_mark for the marker threads;
  • two marker threads are blocked re-acquiring mark_mutex;
  • every other thread is in the suspend handler.

A plain C program reproduces it. Reported upstream as bdwgc/bdwgc#980.

C reproducer, 8 registered threads hangs
bdwgc 8.2.12, parallel marking (default) 5 / 12
bdwgc master e50d792d8a, parallel marking 2 / 12
either, GC_MARKERS=1 0 / 12
bdwgc 8.2.12 built with this change 0 / 8

The cost is that marking runs on the collecting thread alone.

Not solved by this

A tslang gc library whose exported function calls array.join over 200 fresh strings, called from 8 foreign threads, still hangs in 6 of 12 runs with this change (it hung in every run with parallel marking). The stuck state is different: the collector waits in GC_start_world for restart acknowledgements while every other thread has already left the suspend handler. I have not reproduced this mode in pure C yet, so it isn't attributed to Boehm. It's the next thing to investigate. Until then, -mm=rc remains the safe model for Android app libraries.

Verified on the x86_64 emulator only; arm64 was rebuilt but not run.

🤖 Generated with Claude Code

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
bdwgc/bdwgc#980. Marking now runs on the
collecting thread alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 3515194 into main Oct 5, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the android-gc-no-parallel-mark branch October 5, 2026 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant