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

Đang mở
#15,433 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
42/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust, wasm
Lĩnh vực
backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Rust
Star
18.9k
Fork
2k
Merge trung bình
1 ngày 6 giờ
Pull request đã merge (30 ngày)
238

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của bytecodealliance/wasmtime

Tất cả issue của bytecodealliance/wasmtime

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.