GHC WebAssembly Weekly Update, 2023-01-18

Previous update: https://discourse.haskell.org/t/ghc-webassembly-weekly-update-2023-01-11

  • Wasm backend CI rework (!9661) landed. Will backport to ghc-9.6 branch along with other recent wasm fixes.
  • I wrote a draft tutorial (ghc-wasm-meta!11) on how to compile to WASI reactors with user-defined export functions, allowing one to call exported Haskell functions in the JavaScript host multiple times while preserving the heap state. Also, I’ll open a draft MR to add wasm backend documentation to the GHC user’s guide later this week.
  • wasmtime used to have dwarf support, which means it can parse the dwarf sections in a wasm module and emit native debug info when doing JIT compilation, so that users can use gdb/lldb to debug the wasm module by attaching to the wasmtime process. It’s a very nice feature but broken in practice, crashing with an assertion failure for most non-trivial modules. Luckily, someone recently discovered that merely removing that assertion can sweep the bug under the rug. Now I’m able to debug wasm with gdb, and even though gdb crashes all the time, it’s more or less better than no support at all.
  • A wasm memory overflow issue reported in the GHC testsuite (#22602) has been fixed (!9731). tl;dr: it’s related to GMP’s usage of alloca, which doesn’t play well with the rather small default stack size (64KB) on wasm.
  • Reported another issue: our in-tree GMP tarballs lack the CVE-2021-43618 patch that fixes a potential buffer overflow on 32-bit platforms (#22789). The fix has already been included by @bgamari.
  • A small patch (!9734) to properly skip T18623 on darwin, it was meant to be skipped to avoid transient CI failures but the original patch had a typo.
8 Likes