[BUG] 32-bit processes in Waydroid abort once PID > 65535 (bionic pthread_mutex_t limit) — triggered by GitLab Runner PID churn
When GitLab Runner is active on the host, Waydroid 1.4.3 becomes unstable (“collapses”): we see many SIGABRT tombstones from 32-bit processes and periodic system_server ANRs. Root cause evidenced by logs: 32-bit bionic aborts once the current PID exceeds 65535 (pthread_mutex_t owner field limit). With a large pid_max (e.g. 4194304) and CI spawning lots of short-lived processes, PIDs inside Waydroid quickly exceed 65535; any 32-bit process immediately aborts at process start.
Workaround confirmed: Cap pid_max to 65535. After applying the cap, Waydroid remains stable while GitLab Runner runs heavy workloads.
Disclaimer: I used GPT to summarize all the prompts that led to the fix suggested in this ticket. Too much content to format. I reviewed, looks correct.
Environment
Waydroid (host tools):
waydroid --version # 1.4.3Guest build (Waydroid Lineage Android 11):
Build fingerprint: 'waydroid/lineage_waydroid_x86_64/waydroid_x86_64:11/RQ3A.211001.001/114:userdebug/test-keys'Mixed 64/32 ABI enabled (note the presence of x86):
waydroid shell -- getprop ro.zygote # zygote64_32 waydroid shell -- getprop ro.product.cpu.abilist # x86_64,x86 waydroid shell -- getprop ro.product.cpu.abilist32 # x86 waydroid shell -- getprop ro.product.cpu.abilist64 # x86_64PID maximum before workaround (host and inside guest namespace both at 4,194,304):
cat /proc/sys/kernel/pid_max # 4194304 waydroid shell -- cat /proc/sys/kernel/pid_max # 4194304
Original problem (with GitLab Runner)
- Waydroid is stable when idle.
- When GitLab Runner runs CI jobs (high process churn), Waydroid “collapses”: frequent 32-bit process SIGABRTs, and
system_servershows ANR traces.
Investigation timeline (what we tried and what it showed)
Checked for recent native crashes (tombstones).
Many SIGABRT entries; all show ABI: 'x86' (32-bit) and the same abort message:Abort message: 'Limited by the size of pthread_mutex_t, 32 bit bionic libc only accepts pid <= 65535, but current pid is 189662' signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr -------- ABI: 'x86' /apex/com.android.runtime/lib/bionic/libc.so ... (abort) /apex/com.android.runtime/bin/linker ... (process start)(Repeated across
tombstone_00..tombstone_12with varying PIDs: 189669, 189675, 189772, 189786, …)Verified the abort string exists in 32-bit bionic.
waydroid shell -- toybox strings /apex/com.android.runtime/lib/bionic/libc.so | grep -F "pthread_mutex_t, 32 bit bionic libc only accepts pid <= 65535" # Limited by the size of pthread_mutex_t, 32 bit bionic libc only accepts pid <= 65535, but current pid is %dObserved very large PIDs inside Waydroid during CI load.
waydroid shell -- sh -lc 'ps -Ao pid,comm --sort=pid | tail -n 10' 8242 logcat 65545 audioserver 72242 app_process64 100598 app_process64 101769 app_process64 189894 app_process64 189902 app_process64 190103 sh 190104 toybox 190105 toybox # PIDs >> 65535Captured concurrent ANR traces from
system_server(x86_64).
Example header from/data/anr/anr_2025-09-29-13-53-12-557:----- pid 167619 at 2025-09-29 13:53:12 ----- Cmd line: system_server ABI: 'x86_64'(ANRs appear to be a downstream effect of the surrounding 32-bit processes aborting in a loop.)
Watched tombstones in real time to confirm repeated 32-bit SIGABRTs while CI is busy.
waydroid shell -- sh -lc ' mkdir -p /data/local/tmp/mon && touch /data/local/tmp/mon/ts.ct while :; do for f in $(ls -1t /data/tombstones/tombstone_* 2>/dev/null | head -n 3); do if [ "$f" -nt /data/local/tmp/mon/ts.ct ]; then echo "==== NEW: $f ===="; grep -m1 -E "Abort message|signal|ABI:" "$f" || true; touch -r "$f" /data/local/tmp/mon/ts.ct; fi done sleep 2 done' # Repeated: "signal 6 (SIGABRT) ..." and "ABI: 'x86'"Hypothesis formed: 32-bit bionic uses a PID field in
pthread_mutex_tthat overflows above 65535 and aborts intentionally to avoid corruption. Withpid_max=4194304and heavy PID churn, the guest’s PIDs exceed 65535 quickly; any new 32-bit process (e.g., 32-bit linker) crashes immediately at startup.Mitigation test: cap PID max to 65535 and observe stability.
# host (persistent) echo 'kernel.pid_max=65535' | sudo tee /etc/sysctl.d/99-waydroid-compat.conf sudo sysctl --systemResult: After applying the cap, no new tombstones and Waydroid remains stable while GitLab Runner runs.
Why this proves the root cause
- Direct evidence from libc: the abort reason string is emitted by 32-bit bionic only.
- Every crash is
ABI: 'x86'; 64-bitsystem_serverkeeps running but experiences ANRs amid surrounding instability. - PIDs are observed well above 65535 inside Waydroid during failures.
- Reducing
pid_maxto 65535 immediately stops the crashes, with no other change.
Repro steps
- Ensure host and Waydroid PID max are high:
cat /proc/sys/kernel/pid_max waydroid shell -- cat /proc/sys/kernel/pid_max # both show 4194304 (or any value > 65535) - Confirm mixed ABI and 32-bit availability:
waydroid shell -- getprop ro.zygote # zygote64_32 waydroid shell -- getprop ro.product.cpu.abilist # x86_64,x86 (includes x86) - Create high PID churn (e.g., run CI via GitLab Runner) until guest PIDs exceed 65535:
waydroid shell -- sh -lc 'ps -Ao pid,comm --sort=pid | tail' # verify PIDs > 65535 - Watch new tombstones:
waydroid shell -- sh -lc 'for f in $(ls -1t /data/tombstones/tombstone_* 2>/dev/null | head -n 6); do echo "==== $f ===="; grep -m1 -E "^ABI:|^Abort message|^signal " "$f" || true; done' # Expect: ABI: 'x86' + abort message mentioning "pid <= 65535" and SIGABRT
Workaround (confirmed)
- System-wide cap:
echo 'kernel.pid_max=65535' | sudo tee /etc/sysctl.d/99-waydroid-compat.conf sudo sysctl --system - After this change, Waydroid runs reliably under CI stress; no new 32-bit aborts observed.
What would help from Waydroid (possible fixes / mitigations)
PID cap in the Waydroid PID namespace:
- Apply
kernel.pid_max=65535inside the container’s PID namespace (at LXC start) so the host can keep a larger globalpid_maxif needed. - Alternatively, expose a Waydroid config knob (e.g.,
waydroid.propor LXC hook) to enforce this per-container.
- Apply
Disable 32-bit ABI by default (or make it opt-in):
- Ship images with
ro.zygote=zygote64and nox86ABI unless explicitly enabled. This sidesteps the 32-bit bionic limit entirely.
- Ship images with
Early detection & warning:
- On boot, if
ABIincludes 32-bit andpid_max > 65535, log a clear warning (and/or adjust) before processes start, to avoid a crash loop.
- On boot, if
Documentation note:
- Add a troubleshooting entry: “If you run CI or anything that rapidly consumes PIDs and you keep
pid_max> 65535, 32-bit apps may crash with the bionicpthread_mutex_tPID limit. Setkernel.pid_max=65535or disable 32-bit ABI.”
- Add a troubleshooting entry: “If you run CI or anything that rapidly consumes PIDs and you keep
Representative logs (excerpts)
Tombstone (x86) with the defining abort string:
==== /data/tombstones/tombstone_00 ==== ABI: 'x86' signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr -------- Abort message: 'Limited by the size of pthread_mutex_t, 32 bit bionic libc only accepts pid <= 65535, but current pid is 189662' #01 pc ... /apex/com.android.runtime/lib/bionic/libc.so (abort) #06 pc ... /apex/com.android.runtime/bin/linker (... process start)stringson 32-bit libc confirming the check:Limited by the size of pthread_mutex_t, 32 bit bionic libc only accepts pid <= 65535, but current pid is %dANR header (side effect) shows 64-bit
system_server:----- pid 167619 at 2025-09-29 13:53:12 ----- Cmd line: system_server ABI: 'x86_64'PID values inside Waydroid during failure:
65545 audioserver 100598 app_process64 189894 app_process64 190104 toybox
Current status
After applying the host-level workaround:
cat /proc/sys/kernel/pid_max
# 65535
waydroid shell -- cat /proc/sys/kernel/pid_max
# 65535Waydroid remains stable under GitLab Runner load; no new 32-bit SIGABRT tombstones or system_server ANRs observed.
Ask
- Please consider implementing a per-Waydroid PID cap (or defaulting to 64-bit-only images) to prevent this failure mode on hosts that need a large global
pid_max. Happy to provide more logs or test a patch.
Waydroid version
1.4.3
Device
Linux Desktop
Operating System
Debian
Kernel version
6.1.0-40-amd64
Desktop Environment
VPS, wayland, sway, wayvnc
GPU
None, software mode in VPS
Logs
Already cherrypicked the important logs
Source: waydroid/waydroid