#2071·waydroid

[BUG] 32-bit processes in Waydroid abort once PID > 65535 (bionic pthread_mutex_t limit) — triggered by GitLab Runner PID churn

Author: adrian-moisaCreated Sep 30, 2025Updated Sep 21, 2026

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):

    bash
    waydroid --version
    # 1.4.3
  • Guest 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):

    bash
    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_64
  • PID maximum before workaround (host and inside guest namespace both at 4,194,304):

    bash
    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_server shows ANR traces.

Investigation timeline (what we tried and what it showed)

  1. 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_12 with varying PIDs: 189669, 189675, 189772, 189786, …)

  2. Verified the abort string exists in 32-bit bionic.

    bash
    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 %d
  3. Observed very large PIDs inside Waydroid during CI load.

    bash
    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 >> 65535
  4. Captured 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.)

  5. Watched tombstones in real time to confirm repeated 32-bit SIGABRTs while CI is busy.

    bash
    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'"
  6. Hypothesis formed: 32-bit bionic uses a PID field in pthread_mutex_t that overflows above 65535 and aborts intentionally to avoid corruption. With pid_max=4194304 and heavy PID churn, the guest’s PIDs exceed 65535 quickly; any new 32-bit process (e.g., 32-bit linker) crashes immediately at startup.

  7. Mitigation test: cap PID max to 65535 and observe stability.

    bash
    # host (persistent)
    echo 'kernel.pid_max=65535' | sudo tee /etc/sysctl.d/99-waydroid-compat.conf
    sudo sysctl --system

    Result: 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-bit system_server keeps running but experiences ANRs amid surrounding instability.
  • PIDs are observed well above 65535 inside Waydroid during failures.
  • Reducing pid_max to 65535 immediately stops the crashes, with no other change.

Repro steps

  1. Ensure host and Waydroid PID max are high:
    bash
    cat /proc/sys/kernel/pid_max
    waydroid shell -- cat /proc/sys/kernel/pid_max
    # both show 4194304 (or any value > 65535)
  2. Confirm mixed ABI and 32-bit availability:
    bash
    waydroid shell -- getprop ro.zygote                # zygote64_32
    waydroid shell -- getprop ro.product.cpu.abilist   # x86_64,x86 (includes x86)
  3. Create high PID churn (e.g., run CI via GitLab Runner) until guest PIDs exceed 65535:
    bash
    waydroid shell -- sh -lc 'ps -Ao pid,comm --sort=pid | tail'
    # verify PIDs > 65535
  4. Watch new tombstones:
    bash
    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:
    bash
    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)

  1. PID cap in the Waydroid PID namespace:

    • Apply kernel.pid_max=65535 inside the container’s PID namespace (at LXC start) so the host can keep a larger global pid_max if needed.
    • Alternatively, expose a Waydroid config knob (e.g., waydroid.prop or LXC hook) to enforce this per-container.
  2. Disable 32-bit ABI by default (or make it opt-in):

    • Ship images with ro.zygote=zygote64 and no x86 ABI unless explicitly enabled. This sidesteps the 32-bit bionic limit entirely.
  3. Early detection & warning:

    • On boot, if ABI includes 32-bit and pid_max > 65535, log a clear warning (and/or adjust) before processes start, to avoid a crash loop.
  4. 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 bionic pthread_mutex_t PID limit. Set kernel.pid_max=65535 or disable 32-bit ABI.”

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)
  • strings on 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 %d
  • ANR 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:

bash
cat /proc/sys/kernel/pid_max
# 65535
waydroid shell -- cat /proc/sys/kernel/pid_max
# 65535

Waydroid 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