You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A reclaim's Android snapshot load can hang without limit and hold the device #1047
An Android emulator's lease ended and Simlock reclaimed it with standard clean, which loads the clean-baseline snapshot with adb -s <serial> emu avd snapshot load simlock_clean_baseline (reclaim in src/drivers/android/index.ts, line 1126 on main at 7ac7f18). That command never returned: the reclaim sat for 18 minutes before we stopped it, the device stayed in reclaiming, and with android.maxRunning at 1 no other Android lease could be granted meanwhile. The load runs through #runOrThrow without a timeoutMs, and the process runner sets none by default, so nothing ends it.
What you expected
A snapshot load that does not finish within a bounded time (a minute, say) is given up, the emulator is shut down, and the reclaim falls back to the existing shutdown-and-wipe path, so the slot comes back.
How to reproduce
It happened once, in our first half-hour of running Android leases as reusable; we have no reliable trigger. The path, with a reusable Android device:
simlock daemon start (config: lease.identity.android left at reusable, capacity.config.limits.android.maxRunning: 1)
simlock lease --platform android and release it (the first boot captures the clean baseline)
Lease and release again (ours hung on a busy machine, load average well above its core count; we do not know that load is the cause)
When the snapshot load stalls, the reclaim never ends and every later Android lease waits.
Environment
Simlock 0.3.0 at commit 6316e10 (the Android driver is unchanged on main at 7ac7f18), Android only. macOS 27.0.1 on an M5 Max (128 GB), Xcode 27.1, Android emulator 37.2.12, platform-tools 37.0.1, cmdline-tools 22.0, image system-images;android-37.0;google_apis;arm64-v8a, Simlock's default Pixel 9 profile. simlock doctor output was not captured at the time.
Logs and evidence
No daemon log of the hang was kept. The device stayed reclaiming for 18 minutes; adb emu avd snapshot load was still running when we stopped it. We worked around it by setting lease.identity.android to fresh, which skips the snapshot load. We have a tested change that gives the load a 60 s deadline (on the driver clock) and then kills the emulator and wipes; happy to open it as a PR if you want it.
Defect, confirmed as reported. Branch bug/1047-repro, src/drivers/android/index.test.ts: "ends a standard reclaim whose clean-baseline load never answers: the load is stopped, the emulator shut down, and the next boot wipes". The load hangs; the driver's clock moves ten minutes.
pnpm exec vitest run --project unit src/drivers/android/index.test.ts -t "never answers"
AssertionError: expected 'still running' to deeply equal { state: 'shutdown', strategy: 'wipe' }
❯ src/drivers/android/index.test.ts:854
It also asserts the hung adb child ends, emu kill is sent, and the next makeReady uses -wipe-data.
Root cause
src/drivers/android/index.ts:1141 (on ce8fea8) runs emu avd snapshot load through #runOrThrow with no timeoutMs. NodeProcessRunner.run sets no timer when none is given (src/ports/process-runner.ts:203). The wait has no bound (architecture rule 11) and the device lock is held through it. The existing fallback at line 1150 (shut down, wipe) runs only once the load returns. The symptom shows up in core as a device stuck in reclaiming that holds maxRunning.
Simplest fix
Spawn the load and wait for it with the existing #waitForExit(handle, SNAPSHOT_LOAD_TIMEOUT_MS) on the driver clock (60 s, as the reporter proposes). On timeout, kill("SIGKILL") the child and take the same shutdown-and-wipe branch as a failed load. Also treat a non-zero exit as a failed load. A scratch version passed the whole file.
Alternatives rejected
timeoutMs on #runOrThrow: the timer runs on real time, outside the driver clock, so the test cannot see it, and the throw skips the wipe fallback.
Making fresh the default Android identity: hides the hang without bounding it.
The triage's Simplest fix says a non-zero exit of emu avd snapshot load counts as a failed load and takes the shutdown-and-wipe path. No test pinned that line.
Decision: a non-zero exit of the clean-baseline load takes the same shutdown-and-wipe path as a load that times out (decided in delivery, pending the maintainer).
Tests: the reclaim test for the hung load gets a second case, a load that exits non-zero, with the same assertions ({ state: "shutdown", strategy: "wipe" }, emu kill sent, the next makeReady uses -wipe-data).
Maintainer confirmed the decision above: a clean-baseline load that exits non-zero takes the shutdown-and-wipe path, the same as a load that times out. Kept as shipped in #1149.
Follow-up: the Android reset this bug hit is replaced in #327 (Named baselines, ADR 0061). Every emulator becomes a copy of a source, booted from the source's snapshot at launch and destroyed after its lease, so no reclaim loads a snapshot into a running emulator any more (task #1205).
Activity
V3RON commentedon Oct 31, 2026
Reproduction
Defect, confirmed as reported. Branch
bug/1047-repro,src/drivers/android/index.test.ts: "ends a standard reclaim whose clean-baseline load never answers: the load is stopped, the emulator shut down, and the next boot wipes". The load hangs; the driver's clock moves ten minutes.It also asserts the hung
adbchild ends,emu killis sent, and the nextmakeReadyuses-wipe-data.Root cause
src/drivers/android/index.ts:1141(on ce8fea8) runsemu avd snapshot loadthrough#runOrThrowwith notimeoutMs.NodeProcessRunner.runsets no timer when none is given (src/ports/process-runner.ts:203). The wait has no bound (architecture rule 11) and the device lock is held through it. The existing fallback at line 1150 (shut down, wipe) runs only once the load returns. The symptom shows up in core as a device stuck inreclaimingthat holdsmaxRunning.Simplest fix
Spawn the load and wait for it with the existing
#waitForExit(handle, SNAPSHOT_LOAD_TIMEOUT_MS)on the driver clock (60 s, as the reporter proposes). On timeout,kill("SIGKILL")the child and take the same shutdown-and-wipe branch as a failed load. Also treat a non-zero exit as a failed load. A scratch version passed the whole file.Alternatives rejected
timeoutMson#runOrThrow: the timer runs on real time, outside the driver clock, so the test cannot see it, and the throw skips the wipe fallback.freshthe default Android identity: hides the hang without bounding it.Risk
emu killhas no deadline either (Android emulator-console calls emu kill, snapshot save and snapshot list have no deadline #1138). It runs before#waitForExitstarts, so a console that stays hung can still stall the fallback. Bound it in the same PR or right after.Side findings
Written by an agent.
V3RON commentedon Oct 31, 2026
Decision
The triage's Simplest fix says a non-zero exit of
emu avd snapshot loadcounts as a failed load and takes the shutdown-and-wipe path. No test pinned that line.{ state: "shutdown", strategy: "wipe" },emu killsent, the nextmakeReadyuses-wipe-data).Written by an agent.
test(android): cover a clean-baseline load that exits non-zero in the…
test(android): pin the 60 s clean-baseline load deadline from both si…
fix(android): bound the clean-baseline snapshot load at 60 s (callsta…
V3RON commentedon Oct 31, 2026
Maintainer confirmed the decision above: a clean-baseline load that exits non-zero takes the shutdown-and-wipe path, the same as a load that times out. Kept as shipped in #1149.
Written by an agent.
V3RON commentedon Nov 2, 2026
Follow-up: the Android reset this bug hit is replaced in #327 (Named baselines, ADR 0061). Every emulator becomes a copy of a source, booted from the source's snapshot at launch and destroyed after its lease, so no reclaim loads a snapshot into a running emulator any more (task #1205).
Written by an agent.