Sibling vCPUs keep running through a MAP_SHARED overlay

Offen
#495 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
48/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
c, go, macos

Rechercherichtung

Start in src/syscall/proc.c at vcpu_handle_canceled_exit (around lines 4593–4655) and trace its EL1 and signal-delivery returns against thread_fork_barrier_check. Review hvf_apply_file_overlay_quiesced and the normal worker exit path in src/runtime/forkipc.c to understand the impact. Reproduce with the Go 1.23 workload and GOMAXPROCS=4; done means siblings stay quiesced through the overlay and the reported crashes and hangs no longer reproduce.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug

thread_quiesce_siblings does not hold every sibling. The quiesce kicks each sibling with hv_vcpus_exit, but vcpu_handle_canceled_exit can return VCPU_RESUME before it reaches thread_fork_barrier_check (src/syscall/proc.c:4655). Two branches do this: the EL1 early return (:4593) and the signal-delivery branch (:4641). The kick is one-shot, and the quiesce raises no attention bit, so that sibling keeps running guest code. When the caller is hvf_apply_file_overlay_quiesced, which calls hv_vm_unmap on the segment, the sibling takes a stage-2 translation fault:

unexpected exception EC=0x20 syndrome=0x82000007 VA=0x83950 PA=0x83950
unexpected exception EC=0x20 syndrome=0x82000086 VA=0x83950 PA=0xfeff010950

The second form has S1PTW set and faults on the page-table pool.

When the faulting vCPU is a worker, its run loop stops, the thread goes through the normal exit path (src/runtime/forkipc.c:1160), and the 128 exit code is dropped. The process keeps running one thread short. A Go guest then hangs with every remaining thread in futex_wait. Linux would kill the thread group with SIGSEGV instead.

Reproduce: Go 1.23 telemetry mmaps its counter file MAP_SHARED, so any Go tool does this. On upstream main 170b5df, with golang:1.23-alpine through scripts/elfuse-oci.py, each iteration runs go env GOROOT and then gofmt -l over net, runtime and crypto and gofmt -d over fmt, with GOMAXPROCS=4:

  • with GODEBUG=schedtrace=10: 20 crash reports and 2 hangs in 59 iterations
  • without schedtrace: 0 in 400
  • with schedtrace after go telemetry off: 0 in 60

It is not clear why schedtrace raises the rate.

Calling thread_fork_barrier_check() at the top of vcpu_handle_canceled_exit, before the EL1 early return, gave 0 crashes in 120 iterations, and the make check unit suites pass with it. Moving the check above only the signal branch was not enough (4 crashes in 8 iterations). A kick to a vCPU that is outside hv_vcpu_run is held for the next run (checked: CANCELED within 0.002 ms), so the gap is in how the CANCELED exit is handled, not a lost kick.

Vorherrschende Sprache
C
Sterne
287
Forks
33
Ø Merge
2 T. 17 Std.
Gemergte PRs (30 T.)
18

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus sysprog21/elfuse

Alle Issues in sysprog21/elfuse

Ähnliche Issues

Weitere Issues zu C

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.