bug: concurrent VM sandbox launches crash with vCPU "Bad address" (ProcessExited)

Ouverte
#5,902 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
5/5
Temps estimé
Plus d'une semaine
Accessibilité débutants
20/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
rust

Piste de recherche

Reproduce with NEXTEST_TEST_THREADS=4 OPENSHELL_E2E_VM_FEATURES=e2e-conformance-only mise run e2e:vm on a KVM host, then read crates/openshell-driver-vm/src/driver.rs from the image-cache/root-disk planning through the log line "sandbox root disk plan resolved" to the "spawning VM launcher" site, checking whether simultaneous launches share or mutate sandbox-bootstrap-rootfs-ext4-v6 or per-launch host resources. crates/openshell-driver-vm/runtime/pins.env names the libkrun pins to rule in or out. Done means four simultaneous openshell sandbox create calls all reach Ready and the VM lanes pass three runs at four threads with the conformance-only pin from #5865 removed.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

area:drivers

User Story

I maintain OpenShell's E2E conformance suite. While running conformance against VM-driver gateways with four concurrent tests (#5865), I directly hit VM sandboxes that crash during provisioning whenever several start at the same moment on a fresh gateway. Other VM gateway users can hit the same thing by creating several sandboxes at once.

Problem Statement

When several VM sandboxes are created at the same time on a VM-driver gateway that has not launched a VM yet, some of their VMs exit immediately after the launcher starts. In the launcher's output, libkrun reports:

ERROR krun_vmm::linux::vstate] Failure during vcpu run: Bad address (os error 14)
Error:   × VM exited with status 1

The gateway then marks the sandbox Error with ProcessExited: VM process exited, and openshell sandbox create fails with sandbox entered error phase while provisioning: ProcessExited: VM process exited.

Only the first burst of launches fails. In every failing run:

  • The first four creates all pull and prepare the same image (nvcr.io/nvidia/base/ubuntu:24.04) and share the same bootstrap rootfs (sandbox-bootstrap-rootfs-ext4-v6). They finish disk preparation together, and the driver spawns all four VM launchers within about 1 ms (vm driver: spawning VM launcher, crates/openshell-driver-vm/src/driver.rs).
  • About 200 ms later, 1–3 of those four VMs fail with the vCPU Bad address error.
  • All later sandboxes in the same run, still four at a time but no longer starting together, provision and pass. The remaining 45–48 of 49 tests pass.

The same suite passes with one test at a time.

Impact / Why This Matters

  • Creating several VM sandboxes at once, for example from a script, an agent fan-out or a freshly started gateway, can fail with an unhelpful ProcessExited error.
  • The VM E2E lanes have to run conformance serially while Docker, Podman and Kubernetes run four tests at a time (#5865). They give up the roughly 3× conformance speedup the other lanes get.
  • The workaround is to avoid launching VMs at the same time, for example by serializing creates or warming the gateway with one sandbox first. That only hides the race.

Acceptance Criteria

  • Four or more VM sandboxes created at the same time on a fresh VM-driver gateway all reach Ready.
  • The VM E2E lanes pass conformance with NEXTEST_TEST_THREADS: "4" in .github/workflows/e2e-vm-test.yml, three times in a row on all three lanes (managed, external driver, additional CA).
  • The conformance-only lane pin added in #5865 is removed.

Reproduction Steps

Through the conformance suite. This is how the failure was observed, and it reproduces in every run so far.

  1. On Linux x86_64 with /dev/kvm, check out #5865 (or any branch where e2e/support/conformance.sh runs conformance with nextest).
  2. Run the VM lane with four concurrent tests:
    NEXTEST_TEST_THREADS=4 OPENSHELL_E2E_VM_FEATURES=e2e-conformance-only mise run e2e:vm
    
  3. 1–3 of the first tests fail with sandbox entered error phase while provisioning: ProcessExited. The VM launcher's output in the job log contains Failure during vcpu run: Bad address (os error 14).

A shorter form, which I expect to reproduce but have not run on its own: start a fresh VM-driver gateway (as e2e/rust/e2e-vm.sh does), then create four sandboxes simultaneously:

for i in 1 2 3 4; do openshell sandbox create --name race-$i --no-tty --detach & done; wait
Failing CI runs

All at four workers, ubuntu-24.04 GitHub-hosted runners with KVM:

In each job, open the "Run tests" step and search for ProcessExited. The Bad address error was confirmed in all three jobs of run 45235328880; the two earlier runs show the same ProcessExited failures in the first tests.

Where to look

The vCPU Bad address error (EFAULT from KVM_RUN) typically means guest memory backed by a host mapping that is invalid or changing. These are unconfirmed leads:

  • Shared bootstrap rootfs or root-disk preparation. Check whether simultaneous first launches map or open the shared sandbox-bootstrap-rootfs-ext4-v6 image, or a root disk derived from it, while another sandbox is still writing, truncating or replacing it. Look at the image-cache and root-disk planning path before vm driver: sandbox root disk plan resolved in driver.rs.
  • Per-launch host resources set up by openshell-driver-vm or libkrun, such as memory files or sockets, that could collide when launchers start within the same millisecond.
  • libkrun itself (LIBKRUN_REF=227b2de6…, LIBKRUNFW_REF=f14ac64c… in crates/openshell-driver-vm/runtime/pins.env), if the driver-side state is independent per sandbox.

The per-sandbox rootfs-console.log (under the sandbox state directory) and the launcher's stderr for a failed sandbox should show how far the guest got. CI does not upload them today.

Environment

  • OpenShell: 0.1.10-dev.81+g9c7a67494 (gateway and openshell-driver-vm from #5865)
  • OS: GitHub-hosted ubuntu-24.04 runners (x86_64, KVM)
  • Runtime: VM compute driver, both built in and as an external driver
Langage dominant
Rust
Étoiles
21.5k
Forks
2.1k
Métriques de merge des PR
Aucune PR mergée en 30 j

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de NVIDIA/OpenShell

Toutes les issues de NVIDIA/OpenShell

Issues similaires

Plus d'issues Rust

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.