<!-- XE-13369 · Laporan bug · testnet -->
*Markdown view of <https://bounty.xe.network/XE-13369>. The page is the record; this is the same page for reading.*

XE-13369 · Bounty

# Laporan bug

Closed · duplicate
—
[xe#512](https://github.com/xeprotocol/xe/issues/512)
filed 2026-11-12 16:22 UTC
by Gib230223

Verdict
:   Duplicate

Tier
:   —

Claimed
:   —

Area
:   Leasing / ledger

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-20 00:38 UTC

Told
:   2026-11-20 00:34 UTC

### Patches

- [xe#516](https://github.com/xeprotocol/xe/pull/516) open by arturbarszcz78
  fix(vm): cleanup orphaned instance with delete --force on lima create failure (fixes #512)

### History

- [554008](https://bounty.xe.network/log/554008) 2026-11-20 00:34 UTC reply.mirrored
- [553993](https://bounty.xe.network/log/553993) 2026-11-20 00:34 UTC github.state\_pushed
- [553992](https://bounty.xe.network/log/553992) 2026-11-20 00:34 UTC github.labels
- [552429](https://bounty.xe.network/log/552429) 2026-11-20 00:33 UTC proposal.adopted
- [552428](https://bounty.xe.network/log/552428) 2026-11-20 00:33 UTC reply.sent
- [552427](https://bounty.xe.network/log/552427) 2026-11-20 00:33 UTC ticket.status new → closed
- [551813](https://bounty.xe.network/log/551813) 2026-11-20 00:33 UTC proposal.adopted
- [551812](https://bounty.xe.network/log/551812) 2026-11-20 00:33 UTC ticket.facts area
- [551811](https://bounty.xe.network/log/551811) 2026-11-20 00:33 UTC proposal.adopted
- [551810](https://bounty.xe.network/log/551810) 2026-11-20 00:33 UTC ticket.facts
- [551809](https://bounty.xe.network/log/551809) 2026-11-20 00:33 UTC proposal.adopted
- [551808](https://bounty.xe.network/log/551808) 2026-11-20 00:33 UTC ticket.facts

[Full history](https://bounty.xe.network/log?ref=XE-13369) · [JSON](https://bounty.xe.network/v1/tickets/XE-13369) · [markdown](https://bounty.xe.network/XE-13369.md)

### Report

# XE Bounty — Laporan siap file (temuan pass 5 #5)

File issue baru di: https://github.com/xeprotocol/xe/issues/new
Paste judul \+ isi di bawah. Akun GitHub: Gib230223.

---

## Judul

\[Low\] Lima Provision: `limactl create` failure leaks the instance — no `delete --force`, unlike the start/SSH failure paths

## Isi

## Summary

`LimaManager.Provision` has three failure paths after the template is written. The `start` and `waitForSSHPort` paths both clean up (stop \+ `delete --force` \+ remove template). The `create` path removes only the template file — it never deletes the instance. A `create` that fails after the instance exists leaves disk/state behind, blocks re-provision of the same lease name (`limactl create` with the same name fails while the orphan exists), and is only reaped by `cleanOrphans` at next manager construction (node restart).

## Evidence

```
// vm/lima_manager.go:120-123 — create failure: template removed, instance NOT deleted:
if _, err := m.runLimactlWithTimeout(2*time.Minute, "create", "--tty=false", "--name="+name, templatePath); err != nil {
    _ = os.Remove(templatePath)
    return nil, fmt.Errorf("lima create: %w", err)
}

// vm/lima_manager.go:125-133 — start failure: delete --force + template removed:
if _, err := m.runLimactlWithTimeout(5*time.Minute, "start", "--tty=false", name); err != nil {
    diag := m.captureDiagnosticLogs(name)
    _, _ = m.runLimactl("delete", "--force", name)
    _ = os.Remove(templatePath)
    ...
}

// vm/lima_manager.go:135-144 — waitForSSHPort failure: stop + delete --force + template removed:
if _, err := m.waitForSSHPort(name, 2*time.Minute); err != nil {
    diag := m.captureDiagnosticLogs(name)
    _, _ = m.runLimactl("stop", name)
    _, _ = m.runLimactl("delete", "--force", name)
    _ = os.Remove(templatePath)
    ...
}
```

The only other cleanup is `cleanOrphans` (`vm/lima_manager.go:325`), which deletes every `xe-*` limactl instance — but it runs only in the constructor (`NewLimaManager`, line \~85), i.e. at node restart. Within a running process, a failed create leaves a live orphan that also blocks a retry of the same lease: `Provision` checks only its in-memory `m.vms` map (which has no entry for the failed lease), so the retry reaches `limactl create --name=xe-<hash>` again and fails on the existing instance name.

## Impact (Low)

Orphaned Lima instances accumulate on disk after create failures, and the affected lease cannot be re-provisioned until the node restarts (when `cleanOrphans` runs). Severity is Low: narrow trigger (create must fail after the instance exists — e.g. disk provisioning failure), bounded impact (one instance per failed lease, reaped at restart), no fund movement.

## Reproduction (PoC)

Test with a fake `limactl` script, `vm/poc5_lima_create_leak_test.go`, `TestPoc5LimaCreateLeak`, `go test ./vm/ -run TestPoc5LimaCreateLeak -v -count=5`. The fake records every invocation; `create` touches a marker file (simulating the instance on disk) and then fails; `delete --force` removes the marker. Phase 1 stages a create failure and asserts zero `delete --force` calls with the marker still present; phase 2 (control) stages a start failure and asserts `delete --force` IS called.

Coordinator run (2026-11-12 \~23:18 WIB), 5/5 PASS:

```
phase 1: create failed as staged; delete --force calls so far: 0 (want 0); instance marker present: yes
phase 2: start failed as staged; delete --force calls total: 1
BUG REPRODUCED: `limactl create` failure leaves the instance behind (0 delete --force calls), while the `start` failure path cleans up (1 call) — Provision's create error path removes only the template file
```

## Suggested fix

Mirror the start-failure path in the create-failure path:

```
if _, err := m.runLimactlWithTimeout(2*time.Minute, "create", "--tty=false", "--name="+name, templatePath); err != nil {
    _, _ = m.runLimactl("delete", "--force", name)
    _ = os.Remove(templatePath)
    return nil, fmt.Errorf("lima create: %w", err)
}
```

## Novelty note

No ticket covers Lima create-failure cleanup. Closest, all verified: XE-1438 (QEMU/Lima VM managers bind guest SSH on 0.0.0.0, premature SLIRP readiness, GPU FLR, global lock — different defects in the same managers); pass-3 #5 (QEMU *workdir* leak on `waitForQEMUPID`/`waitForSSHPort` failure — different manager, different leaked resource, different failure paths). Board greps for lima/limactl/create-leak/orphan return no ticket; GitHub live `search_issues` returns 0 hits. Checked the live bounty board (High\+Medium and Minor views) and the GitHub repo issues, 2026-11-12.

Repo: github.com/xeprotocol/xe, HEAD 89a542e, testnet-0005.

### Thread

**Joseph Denne**team2026-11-20 00:34 UTCgithub

Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the
first verifiable submission, so this one closes as a duplicate. If you believe it is a different
bug, file a new report that links https://bounty.xe.network/XE-13369 and says what differs; it is read like any other.
