GC zeal counter erroneously causes an allocation requiring >1 page of growth to fail

Offen
#15,433 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
42/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
rust, wasm
Bereich
backend

Rechercherichtung

Start by reproducing with RUSTFLAGS="--cfg gc_zeal" cargo run wast -Ogc-zeal-alloc-counter=1 foo.wast and comparing against the run without the zeal flag; the wast file in the body is the whole reproducer. Then read the zeal allocation path that synthesizes the out-of-memory error and the GC heap growth routine that reads bytes_needed from it, since the two disagree when the reported need is 0. Done means the multi-page array.new_default of 65500 elements succeeds under zeal while still forcing growth and collection each allocation.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

wasm-proposal:gc

This test:

(module
  (type $a (array (mut i8)))
  (func (export "alloc") (param i32) (result i32)
    (array.len (array.new_default $a (local.get 0)))))

(assert_return (invoke "alloc" (i32.const 65500)) (i32.const 65500))

fails with:

$ RUSTFLAGS="--cfg gc_zeal" cargo run wast -Ogc-zeal-alloc-counter=1 foo.wast
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.09s
     Running `target/debug/wasmtime wast -Ogc-zeal-alloc-counter=1 foo.wast`
Error: failed to run script file 'foo.wast'

Caused by:
    0: failed directive on foo.wast:6
    1: error while executing at wasm backtrace:
           0:     0x29 - wasm-function[0]
                           at ./foo.wast:4:17
    2: GC heap out of memory: no capacity for allocation of 131072 bytes

but passes with:

$ RUSTFLAGS="--cfg gc_zeal" cargo run wast foo.wast
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.10s
     Running `target/debug/wasmtime wast -Ccollector=drc -Wgc foo.wast`

GC heap growth is based on the bytes_needed of the error, but GC zeal injects an error with bytes_needed == 0, so if more than one page is needed the re-attempted allocation after growth still fails, causing the entire allocation to fail.

cc @fitzgen

Vorherrschende Sprache
Rust
Sterne
18.9k
Forks
2k
Ø Merge
1 T. 6 Std.
Gemergte PRs (30 T.)
238

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 bytecodealliance/wasmtime

Alle Issues in bytecodealliance/wasmtime

Ähnliche Issues

Weitere Issues zu Rust

Neue Issues direkt in Ihr Postfach

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