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

Aperta
#15,433 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
rust, wasm
Ambito
backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
Rust
Stelle
18.9k
Fork
2k
Merge medio
1g 6h
PR unite (30g)
238

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di bytecodealliance/wasmtime

Tutte le issue di bytecodealliance/wasmtime

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.