Stream: git-wasmtime

Topic: wasmtime / issue #14325 gc_ops fuzzbug: Potential leak in...


view this post on Zulip Wasmtime GitHub notifications bot (Sep 12 2026 at 23:15):

khagankhan opened issue #14325:

I was fuzzing wasmtime locally with gc_ops and I think there may be potential leak in the DRC. Reduced to wast for easier debug, so there is no need for fmt.

wasmtime 50.0.0-dev (2be5e3a62 2026-09-11)

table.fill with a constant ref.null on a GC-reference table is lowered to a memset when -O table-lazy-init=n bypassing the DRC write barrier. The eligibility check allows_memset permits the fast path for any table once lazy init is off. array.fill seems to be working correctly.

For the given file:

(module
  (type $bytes (array (mut i8)))
  (table $t 1 anyref)
  (func (export "run") (param $n i32)
    (loop $l
      (table.set $t (i32.const 0) (array.new_default $bytes (i32.const 65536)))
      (table.fill $t (i32.const 0) (ref.null any) (i32.const 1))
      (local.set $n (i32.sub (local.get $n) (i32.const 1)))
      (br_if $l (local.get $n)))))
(assert_return (invoke "run" (i32.const 100000)))
  1. Allocate 64KB array.
  2. Set it to the table slot 0
  3. Overwrite that slot with ref.null any

So at the end of each iteration the array becomes unreachable (garbage) that should be collected at some point.

Actual behavior:

$ time  wasmtime wast -C collector=drc -O table-lazy-init=n t.wast

Error: failed to run script file 't.wast'

Caused by:
    0: failed directive on t.wast:10
    1: error while executing at wasm backtrace:
    0:     0x33 - wasm-function[0]
                    at ./t.wast:6:36
    2: GC heap out of memory: no capacity for allocation of 65564 bytes


real    0m53.094s
user    0m48.324s
sys     0m4.504s

<details>
<summary>Trace Execution of Actual Behavior</summary>

2026-09-12T21:46:30.936173Z TRACE wasmtime::runtime::store::gc: ============ Begin GC ===========
                  GC heap capacity = 0x40000000 bytes
        last post-GC live-set size = 0x0fffffc0 bytes
               GC heap utilization = 25.00%
2026-09-12T21:46:30.936226Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots
2026-09-12T21:46:30.936260Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: Wasm stack
2026-09-12T21:46:30.936405Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: Wasm stack
2026-09-12T21:46:30.936535Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: continuations
2026-09-12T21:46:30.936581Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: continuations
2026-09-12T21:46:30.936644Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: vmctx
2026-09-12T21:46:30.936725Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: vmctx
2026-09-12T21:46:30.936791Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: instance
2026-09-12T21:46:30.936835Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: instance
2026-09-12T21:46:30.936893Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: user
2026-09-12T21:46:30.936942Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: user
2026-09-12T21:46:30.936998Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: pending exception
2026-09-12T21:46:30.937034Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: pending exception
2026-09-12T21:46:30.937068Z TRACE wasmtime::runtime::store::gc: End trace GC roots
2026-09-12T21:46:31.188664Z TRACE wasmtime::runtime::store::gc: ============ End GC ===========
             GC heap capacity = 0x40000000 bytes
        post-GC live-set size = 0x3fffff00 bytes
          GC heap utilization = 100.00%
2026-09-12T21:46:31.188825Z TRACE wasmtime::runtime::store::gc: Attempting to grow the GC heap by at least 0x1001c bytes
2026-09-12T21:46:31.188944Z TRACE wasmtime::runtime::store::gc:   -> grew GC heap by 0x40000000 bytes: new size is 0x80000000 bytes
2026-09-12T21:46:44.379767Z TRACE wasmtime::runtime::store::gc: Got GC heap OOM: GC heap out of memory: no capacity for allocation of 65564 bytes
2026-09-12T21:46:44.379869Z TRACE wasmtime::runtime::store::gc: Grow GC heap first, collecting if growth failed, then retrying
2026-09-12T21:46:44.379904Z TRACE wasmtime::runtime::store::gc: Attempting to grow the GC heap by at least 0x1001c bytes
2026-09-12T21:46:44.379990Z TRACE wasmtime::runtime::store::gc:   -> grew GC heap by 0x80000000 bytes: new size is 0x100000000 bytes
2026-09-12T21:47:10.116957Z TRACE wasmtime::runtime::store::gc: Got GC heap OOM: GC heap out of memory: no capacity for allocation of 65564 bytes
2026-09-12T21:47:10.117057Z TRACE wasmtime::runtime::store::gc: Collecting first, then retrying; growing GC heap if collecting didn't free up enough space, then retrying again
2026-09-12T21:47:10.117106Z TRACE wasmtime::runtime::store::gc: collect_and_maybe_grow_gc_heap(bytes_needed = None)
2026-09-12T21:47:10.117143Z TRACE wasmtime::runtime::store::gc: ============ Begin GC ===========
                  GC heap capacity = 0x100000000 bytes
        last post-GC live-set size = 0x3fffff00 bytes
               GC heap utilization = 25.00%
2026-09-12T21:47:10.117190Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots
2026-09-12T21:47:10.117214Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: Wasm stack
2026-09-12T21:47:10.117367Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: Wasm stack
2026-09-12T21:47:10.117506Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: continuations
2026-09-12T21:47:10.117549Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: continuations
2026-09-12T21:47:10.117600Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: vmctx
2026-09-12T21:47:10.117683Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: vmctx
2026-09-12T21:47:10.117742Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: instance
2026-09-12T21:47:10.117782Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: instance
2026-09-12T21:47:10.117830Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: user
2026-09-12T21:47:10.117877Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: user
2026-09-12T21:47:10.117925Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: pending exception
2026-09-12T21:47:10.117956Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: pending exception
2026-09-12T21:47:10.117980Z TRACE wasmtime::runtime::store::gc: End trace GC roots
2026-09-12T21:47:10.980060Z TRACE wasmtime::runtime::store::gc: ============ End GC ===========
             GC heap capacity = 0x100000000 bytes
        post-GC live-set size = 0xfffffc00 bytes
          GC heap utilization = 100.00%
2026-09-12T21:47:10.980342Z TRACE wasmtime::runtime::store::gc: Attempting to grow the GC heap by at least 0x1001c bytes
Error: failed to run script file 't.wast'

Caused by:
    0: failed directive on t.wast:10
    1: error while executing at wasm backtrace:
    0:     0x33 - wasm-function[0]
                    at ./t.wast:6:36
    2: GC heap out of memory: no capacity for allocation of 65564 bytes

</details>

Expected behavior:

$ time wasmtime wast -C collector=drc -O table-lazy-init=y t.wast

real    4m20.215s
user    4m18.943s
sys     0m0.049s

<details>
<summary>Trace Execution of Expected Behavior</summary>

2026-09-12T22:52:48.882121Z TRACE wasmtime::runtime::store::gc: ============ Begin GC ===========
                  GC heap capacity = 0x00040000 bytes
        last post-GC live-set size = 0x00000000 bytes
               GC heap utilization = 0.00%
2026-09-12T22:52:48.882211Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots
2026-09-12T22:52:48.882250Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: Wasm stack
2026-09-12T22:52:48.882436Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: Wasm stack
2026-09-12T22:52:48.882592Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: continuations
2026-09-12T22:52:48.882643Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: continuations
2026-09-12T22:52:48.882706Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: vmctx
2026-09-12T22:52:48.882803Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: vmctx
2026-09-12T22:52:48.882867Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: instance
2026-09-12T22:52:48.882925Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: instance
2026-09-12T22:52:48.882985Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: user
2026-09-12T22:52:48.883041Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: user
2026-09-12T22:52:48.883101Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: pending exception
2026-09-12T22:52:48.883146Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: pending exception
2026-09-12T22:52:48.883186Z TRACE wasmtime::runtime::store::gc: End trace GC roots
2026-09-12T22:52:48.888927Z TRACE wasmtime::runtime::store::gc: ============ End GC ===========
             GC heap capacity = 0x00040000 bytes
        post-GC live-set size = 0x00000000 bytes
          GC heap utilization = 0.00%
2026-09-12T22:52:48.891610Z TRACE wasmtime::runtime::store::gc: Got GC heap OOM: GC heap out of memory: no capacity for allocation of 65564 bytes
2026-09-12T22:52:48.891851Z TRACE wasmtime::runtime::store::gc: Collecting first, then retrying; growing GC heap if collecting didn't free up enough space, then retrying again
2026-09-12T22:52:48.891937Z TRACE wasmtime::runtime::store::gc: collect_and_maybe_grow_gc_heap(bytes_needed = None)
2026-09-12T22:52:48.892004Z TRACE wasmtime::runtime::store::gc: ============ Begin GC ===========
                  GC heap capacity = 0x00040000 bytes
        last post-GC live-set size = 0x00000000 bytes
               GC heap utilization = 0.00%
2026-09-12T22:52:48.892120Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots
2026-09-12T22:52:48.892159Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: Wasm stack
2026-09
[message truncated]

view this post on Zulip Wasmtime GitHub notifications bot (Sep 12 2026 at 23:15):

khagankhan added the bug label to Issue #14325.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 12 2026 at 23:15):

khagankhan added the fuzz-bug label to Issue #14325.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 12 2026 at 23:19):

khagankhan edited issue #14325:

I was fuzzing wasmtime locally with gc_ops and I think there may be potential leak in the DRC. Reduced to wast for easier debug, so there is no need for fmt.

wasmtime 50.0.0-dev (2be5e3a62 2026-09-11)

table.fill with a constant ref.null on a GC-reference table is lowered to a memset when -O table-lazy-init=n bypassing the DRC write barrier. The eligibility check allows_memset permits the fast path for any table once lazy init is off. array.fill seems to be working correctly.

For the given file:

(module
  (type $bytes (array (mut i8)))
  (table $t 1 anyref)
  (func (export "run") (param $n i32)
    (loop $l
      (table.set $t (i32.const 0) (array.new_default $bytes (i32.const 65536)))
      (table.fill $t (i32.const 0) (ref.null any) (i32.const 1))
      (local.set $n (i32.sub (local.get $n) (i32.const 1)))
      (br_if $l (local.get $n)))))
(assert_return (invoke "run" (i32.const 100000)))
  1. Allocate 64KB array.
  2. Set it to the table slot 0
  3. Overwrite that slot with ref.null any

So at the end of each iteration the array becomes unreachable (garbage) that should be collected at some point.

Actual behavior:

time ./target/release/wasmtime wast -C collector=drc -O table-lazy-init=n t.wast
Error: failed to run script file 't.wast'

Caused by:
    0: failed directive on t.wast:10
    1: error while executing at wasm backtrace:
    0:     0x33 - wasm-function[0]
                    at ./t.wast:6:36
    2: GC heap out of memory: no capacity for allocation of 65564 bytes


real    0m5.701s
user    0m1.110s
sys     0m4.536s

<details>
<summary>Trace Execution of Actual Behavior</summary>

2026-09-12T21:46:30.936173Z TRACE wasmtime::runtime::store::gc: ============ Begin GC ===========
                  GC heap capacity = 0x40000000 bytes
        last post-GC live-set size = 0x0fffffc0 bytes
               GC heap utilization = 25.00%
2026-09-12T21:46:30.936226Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots
2026-09-12T21:46:30.936260Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: Wasm stack
2026-09-12T21:46:30.936405Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: Wasm stack
2026-09-12T21:46:30.936535Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: continuations
2026-09-12T21:46:30.936581Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: continuations
2026-09-12T21:46:30.936644Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: vmctx
2026-09-12T21:46:30.936725Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: vmctx
2026-09-12T21:46:30.936791Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: instance
2026-09-12T21:46:30.936835Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: instance
2026-09-12T21:46:30.936893Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: user
2026-09-12T21:46:30.936942Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: user
2026-09-12T21:46:30.936998Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: pending exception
2026-09-12T21:46:30.937034Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: pending exception
2026-09-12T21:46:30.937068Z TRACE wasmtime::runtime::store::gc: End trace GC roots
2026-09-12T21:46:31.188664Z TRACE wasmtime::runtime::store::gc: ============ End GC ===========
             GC heap capacity = 0x40000000 bytes
        post-GC live-set size = 0x3fffff00 bytes
          GC heap utilization = 100.00%
2026-09-12T21:46:31.188825Z TRACE wasmtime::runtime::store::gc: Attempting to grow the GC heap by at least 0x1001c bytes
2026-09-12T21:46:31.188944Z TRACE wasmtime::runtime::store::gc:   -> grew GC heap by 0x40000000 bytes: new size is 0x80000000 bytes
2026-09-12T21:46:44.379767Z TRACE wasmtime::runtime::store::gc: Got GC heap OOM: GC heap out of memory: no capacity for allocation of 65564 bytes
2026-09-12T21:46:44.379869Z TRACE wasmtime::runtime::store::gc: Grow GC heap first, collecting if growth failed, then retrying
2026-09-12T21:46:44.379904Z TRACE wasmtime::runtime::store::gc: Attempting to grow the GC heap by at least 0x1001c bytes
2026-09-12T21:46:44.379990Z TRACE wasmtime::runtime::store::gc:   -> grew GC heap by 0x80000000 bytes: new size is 0x100000000 bytes
2026-09-12T21:47:10.116957Z TRACE wasmtime::runtime::store::gc: Got GC heap OOM: GC heap out of memory: no capacity for allocation of 65564 bytes
2026-09-12T21:47:10.117057Z TRACE wasmtime::runtime::store::gc: Collecting first, then retrying; growing GC heap if collecting didn't free up enough space, then retrying again
2026-09-12T21:47:10.117106Z TRACE wasmtime::runtime::store::gc: collect_and_maybe_grow_gc_heap(bytes_needed = None)
2026-09-12T21:47:10.117143Z TRACE wasmtime::runtime::store::gc: ============ Begin GC ===========
                  GC heap capacity = 0x100000000 bytes
        last post-GC live-set size = 0x3fffff00 bytes
               GC heap utilization = 25.00%
2026-09-12T21:47:10.117190Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots
2026-09-12T21:47:10.117214Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: Wasm stack
2026-09-12T21:47:10.117367Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: Wasm stack
2026-09-12T21:47:10.117506Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: continuations
2026-09-12T21:47:10.117549Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: continuations
2026-09-12T21:47:10.117600Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: vmctx
2026-09-12T21:47:10.117683Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: vmctx
2026-09-12T21:47:10.117742Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: instance
2026-09-12T21:47:10.117782Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: instance
2026-09-12T21:47:10.117830Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: user
2026-09-12T21:47:10.117877Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: user
2026-09-12T21:47:10.117925Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: pending exception
2026-09-12T21:47:10.117956Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: pending exception
2026-09-12T21:47:10.117980Z TRACE wasmtime::runtime::store::gc: End trace GC roots
2026-09-12T21:47:10.980060Z TRACE wasmtime::runtime::store::gc: ============ End GC ===========
             GC heap capacity = 0x100000000 bytes
        post-GC live-set size = 0xfffffc00 bytes
          GC heap utilization = 100.00%
2026-09-12T21:47:10.980342Z TRACE wasmtime::runtime::store::gc: Attempting to grow the GC heap by at least 0x1001c bytes
Error: failed to run script file 't.wast'

Caused by:
    0: failed directive on t.wast:10
    1: error while executing at wasm backtrace:
    0:     0x33 - wasm-function[0]
                    at ./t.wast:6:36
    2: GC heap out of memory: no capacity for allocation of 65564 bytes

</details>

Expected behavior:

time ./target/release/wasmtime wast -C collector=drc -O table-lazy-init=y t.wast

real    0m0.671s
user    0m0.650s
sys     0m0.011s

<details>
<summary>Trace Execution of Expected Behavior</summary>

2026-09-12T22:52:48.882121Z TRACE wasmtime::runtime::store::gc: ============ Begin GC ===========
                  GC heap capacity = 0x00040000 bytes
        last post-GC live-set size = 0x00000000 bytes
               GC heap utilization = 0.00%
2026-09-12T22:52:48.882211Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots
2026-09-12T22:52:48.882250Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: Wasm stack
2026-09-12T22:52:48.882436Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: Wasm stack
2026-09-12T22:52:48.882592Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: continuations
2026-09-12T22:52:48.882643Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: continuations
2026-09-12T22:52:48.882706Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: vmctx
2026-09-12T22:52:48.882803Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: vmctx
2026-09-12T22:52:48.882867Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: instance
2026-09-12T22:52:48.882925Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: instance
2026-09-12T22:52:48.882985Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: user
2026-09-12T22:52:48.883041Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: user
2026-09-12T22:52:48.883101Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: pending exception
2026-09-12T22:52:48.883146Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: pending exception
2026-09-12T22:52:48.883186Z TRACE wasmtime::runtime::store::gc: End trace GC roots
2026-09-12T22:52:48.888927Z TRACE wasmtime::runtime::store::gc: ============ End GC ===========
             GC heap capacity = 0x00040000 bytes
        post-GC live-set size = 0x00000000 bytes
          GC heap utilization = 0.00%
2026-09-12T22:52:48.891610Z TRACE wasmtime::runtime::store::gc: Got GC heap OOM: GC heap out of memory: no capacity for allocation of 65564 bytes
2026-09-12T22:52:48.891851Z TRACE wasmtime::runtime::store::gc: Collecting first, then retrying; growing GC heap if collecting didn't free up enough space, then retrying again
2026-09-12T22:52:48.891937Z TRACE wasmtime::runtime::store::gc: collect_and_maybe_grow_gc_heap(bytes_needed = None)
2026-09-12T22:52:48.892004Z TRACE wasmtime::runtime::store::gc: ============ Begin GC ===========
                  GC heap capacity = 0x00040000 bytes
        last post-GC live-set size = 0x00000000 bytes
               GC heap utilization = 0.00%
2026-09-12T22:52:48.892120Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots
2026-09-12T22:52:48.892159Z TRACE wasmtime::runtime::store::gc: Begin trace GC roo
[message truncated]

view this post on Zulip Wasmtime GitHub notifications bot (Sep 14 2026 at 14:55):

alexcrichton commented on issue #14325:

Definitely a bug, thanks! Should be fixed over at https://github.com/bytecodealliance/wasmtime/pull/14328

view this post on Zulip Wasmtime GitHub notifications bot (Sep 14 2026 at 15:33):

cfallin closed issue #14325:

I was fuzzing wasmtime locally with gc_ops and I think there may be potential leak in the DRC. Reduced to wast for easier debug, so there is no need for fmt.

wasmtime 50.0.0-dev (2be5e3a62 2026-09-11)

table.fill with a constant ref.null on a GC-reference table is lowered to a memset when -O table-lazy-init=n bypassing the DRC write barrier. The eligibility check allows_memset permits the fast path for any table once lazy init is off. array.fill seems to be working correctly.

For the given file:

(module
  (type $bytes (array (mut i8)))
  (table $t 1 anyref)
  (func (export "run") (param $n i32)
    (loop $l
      (table.set $t (i32.const 0) (array.new_default $bytes (i32.const 65536)))
      (table.fill $t (i32.const 0) (ref.null any) (i32.const 1))
      (local.set $n (i32.sub (local.get $n) (i32.const 1)))
      (br_if $l (local.get $n)))))
(assert_return (invoke "run" (i32.const 100000)))
  1. Allocate 64KB array.
  2. Set it to the table slot 0
  3. Overwrite that slot with ref.null any

So at the end of each iteration the array becomes unreachable (garbage) that should be collected at some point.

Actual behavior:

time ./target/release/wasmtime wast -C collector=drc -O table-lazy-init=n t.wast
Error: failed to run script file 't.wast'

Caused by:
    0: failed directive on t.wast:10
    1: error while executing at wasm backtrace:
    0:     0x33 - wasm-function[0]
                    at ./t.wast:6:36
    2: GC heap out of memory: no capacity for allocation of 65564 bytes


real    0m5.701s
user    0m1.110s
sys     0m4.536s

<details>
<summary>Trace Execution of Actual Behavior</summary>

2026-09-12T21:46:30.936173Z TRACE wasmtime::runtime::store::gc: ============ Begin GC ===========
                  GC heap capacity = 0x40000000 bytes
        last post-GC live-set size = 0x0fffffc0 bytes
               GC heap utilization = 25.00%
2026-09-12T21:46:30.936226Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots
2026-09-12T21:46:30.936260Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: Wasm stack
2026-09-12T21:46:30.936405Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: Wasm stack
2026-09-12T21:46:30.936535Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: continuations
2026-09-12T21:46:30.936581Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: continuations
2026-09-12T21:46:30.936644Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: vmctx
2026-09-12T21:46:30.936725Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: vmctx
2026-09-12T21:46:30.936791Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: instance
2026-09-12T21:46:30.936835Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: instance
2026-09-12T21:46:30.936893Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: user
2026-09-12T21:46:30.936942Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: user
2026-09-12T21:46:30.936998Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: pending exception
2026-09-12T21:46:30.937034Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: pending exception
2026-09-12T21:46:30.937068Z TRACE wasmtime::runtime::store::gc: End trace GC roots
2026-09-12T21:46:31.188664Z TRACE wasmtime::runtime::store::gc: ============ End GC ===========
             GC heap capacity = 0x40000000 bytes
        post-GC live-set size = 0x3fffff00 bytes
          GC heap utilization = 100.00%
2026-09-12T21:46:31.188825Z TRACE wasmtime::runtime::store::gc: Attempting to grow the GC heap by at least 0x1001c bytes
2026-09-12T21:46:31.188944Z TRACE wasmtime::runtime::store::gc:   -> grew GC heap by 0x40000000 bytes: new size is 0x80000000 bytes
2026-09-12T21:46:44.379767Z TRACE wasmtime::runtime::store::gc: Got GC heap OOM: GC heap out of memory: no capacity for allocation of 65564 bytes
2026-09-12T21:46:44.379869Z TRACE wasmtime::runtime::store::gc: Grow GC heap first, collecting if growth failed, then retrying
2026-09-12T21:46:44.379904Z TRACE wasmtime::runtime::store::gc: Attempting to grow the GC heap by at least 0x1001c bytes
2026-09-12T21:46:44.379990Z TRACE wasmtime::runtime::store::gc:   -> grew GC heap by 0x80000000 bytes: new size is 0x100000000 bytes
2026-09-12T21:47:10.116957Z TRACE wasmtime::runtime::store::gc: Got GC heap OOM: GC heap out of memory: no capacity for allocation of 65564 bytes
2026-09-12T21:47:10.117057Z TRACE wasmtime::runtime::store::gc: Collecting first, then retrying; growing GC heap if collecting didn't free up enough space, then retrying again
2026-09-12T21:47:10.117106Z TRACE wasmtime::runtime::store::gc: collect_and_maybe_grow_gc_heap(bytes_needed = None)
2026-09-12T21:47:10.117143Z TRACE wasmtime::runtime::store::gc: ============ Begin GC ===========
                  GC heap capacity = 0x100000000 bytes
        last post-GC live-set size = 0x3fffff00 bytes
               GC heap utilization = 25.00%
2026-09-12T21:47:10.117190Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots
2026-09-12T21:47:10.117214Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: Wasm stack
2026-09-12T21:47:10.117367Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: Wasm stack
2026-09-12T21:47:10.117506Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: continuations
2026-09-12T21:47:10.117549Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: continuations
2026-09-12T21:47:10.117600Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: vmctx
2026-09-12T21:47:10.117683Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: vmctx
2026-09-12T21:47:10.117742Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: instance
2026-09-12T21:47:10.117782Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: instance
2026-09-12T21:47:10.117830Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: user
2026-09-12T21:47:10.117877Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: user
2026-09-12T21:47:10.117925Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: pending exception
2026-09-12T21:47:10.117956Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: pending exception
2026-09-12T21:47:10.117980Z TRACE wasmtime::runtime::store::gc: End trace GC roots
2026-09-12T21:47:10.980060Z TRACE wasmtime::runtime::store::gc: ============ End GC ===========
             GC heap capacity = 0x100000000 bytes
        post-GC live-set size = 0xfffffc00 bytes
          GC heap utilization = 100.00%
2026-09-12T21:47:10.980342Z TRACE wasmtime::runtime::store::gc: Attempting to grow the GC heap by at least 0x1001c bytes
Error: failed to run script file 't.wast'

Caused by:
    0: failed directive on t.wast:10
    1: error while executing at wasm backtrace:
    0:     0x33 - wasm-function[0]
                    at ./t.wast:6:36
    2: GC heap out of memory: no capacity for allocation of 65564 bytes

</details>

Expected behavior:

time ./target/release/wasmtime wast -C collector=drc -O table-lazy-init=y t.wast

real    0m0.671s
user    0m0.650s
sys     0m0.011s

<details>
<summary>Trace Execution of Expected Behavior</summary>

2026-09-12T22:52:48.882121Z TRACE wasmtime::runtime::store::gc: ============ Begin GC ===========
                  GC heap capacity = 0x00040000 bytes
        last post-GC live-set size = 0x00000000 bytes
               GC heap utilization = 0.00%
2026-09-12T22:52:48.882211Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots
2026-09-12T22:52:48.882250Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: Wasm stack
2026-09-12T22:52:48.882436Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: Wasm stack
2026-09-12T22:52:48.882592Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: continuations
2026-09-12T22:52:48.882643Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: continuations
2026-09-12T22:52:48.882706Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: vmctx
2026-09-12T22:52:48.882803Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: vmctx
2026-09-12T22:52:48.882867Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: instance
2026-09-12T22:52:48.882925Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: instance
2026-09-12T22:52:48.882985Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: user
2026-09-12T22:52:48.883041Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: user
2026-09-12T22:52:48.883101Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots :: pending exception
2026-09-12T22:52:48.883146Z TRACE wasmtime::runtime::store::gc: End trace GC roots :: pending exception
2026-09-12T22:52:48.883186Z TRACE wasmtime::runtime::store::gc: End trace GC roots
2026-09-12T22:52:48.888927Z TRACE wasmtime::runtime::store::gc: ============ End GC ===========
             GC heap capacity = 0x00040000 bytes
        post-GC live-set size = 0x00000000 bytes
          GC heap utilization = 0.00%
2026-09-12T22:52:48.891610Z TRACE wasmtime::runtime::store::gc: Got GC heap OOM: GC heap out of memory: no capacity for allocation of 65564 bytes
2026-09-12T22:52:48.891851Z TRACE wasmtime::runtime::store::gc: Collecting first, then retrying; growing GC heap if collecting didn't free up enough space, then retrying again
2026-09-12T22:52:48.891937Z TRACE wasmtime::runtime::store::gc: collect_and_maybe_grow_gc_heap(bytes_needed = None)
2026-09-12T22:52:48.892004Z TRACE wasmtime::runtime::store::gc: ============ Begin GC ===========
                  GC heap capacity = 0x00040000 bytes
        last post-GC live-set size = 0x00000000 bytes
               GC heap utilization = 0.00%
2026-09-12T22:52:48.892120Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots
2026-09-12T22:52:48.892159Z TRACE wasmtime::runtime::store::gc: Begin trace GC roots
[message truncated]


Last updated: Sep 20 2026 at 18:08 UTC