You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Harden Wasmtime's compiled GC code against corruption
In the spirit of #13320 this commit goes through the compiled code for
the GC proposal to ensure that, in the face of GC corruption, Wasmtime
by default can recover and return a "bug" to the embedder. This was also
discussed a bit in #13112 as well, and the changes made here are:
* Plumbing traps from translation into the runtime now uses a new
`CompiledTrap` enum instead of just the normal `Trap`. This new enum
has branches for `InternalAssert` (not previously present) and
additionally `GcHeapCorrupted` (now added).
* Whether or not `CompiledTrap::{InternalAssert,GcHeapCorrupted}` is
encoded into the final `*.cwasm` is now a `Tunables` configuration
option. Internal asserts are not encoded by default but GC heap
corruption is.
* Traps caught as `CompiledTrap::{InternalAssert,GcHeapCorrupted}` are
turned into `WasmtimeBug` and propagated upwards. Traps stay as normal
traps.
* All memory accesses to the GC heap now use
`CompiledTrap::GcHeapCorrupted` as their trap code. Additionally
they're also no longer marked as `readonly` in a few places.
* A few locations in GC translation using `InternalAssert` now use
`GcHeapCorrupted`, such as the checked arithmetic around array
lengths. Other assertions which are about control flow are left
untouched.
The end state is that faults in the GC heap in compiled code itself
should show up as a `bug!` on the other end by default. This requires
extra metadata in `*.cwasm`s mapping traps, but this is similar to
linear-memory-using-wasms which have lots of trap metadata for
loads/stores. Being able to catch `InternalAssert` as a first-class
error (as opposed to a signal) is a debugging nicety I've added here but
remains off-by-default to avoid bloating `*.cwasm`s for internal debugging.
Closes#13112
0 commit comments