Last active
February 9, 2024 02:37
-
-
Save pmp-p/e06d75b541ca38cc3f375ae5eb80a80e to your computer and use it in GitHub Desktop.
gc orc/arc bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# wasi-sdk from https://github.com/WebAssembly/wasi-sdk/releases | |
# Nim git | |
PATH=/opt/wasi-sdk-21.0/bin:$PATH ./Nim/bin/nim \ | |
--exceptions:goto \ | |
--cc:clang -d:wasi --threads:off -d:emscripten --cpu:wasm32 \ | |
--passC="-m32 -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_MMAN" \ | |
--passL="-m32 -Wl,--export-all -mexec-model=reactor -lwasi-emulated-signal -lwasi-emulated-mman" \ | |
-r c --out:out.wasi repro_inittable.nim | |
wasmtime --invoke setup $(pwd)/out.wasi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std/tables | |
var | |
# initTable will crash on wasi | |
table = initTable[string, Table[int, proc () : void] ]() | |
# this will not | |
# table : Table[string, Table[int, proc () : void] ] | |
when defined(wasi): | |
proc initialize(argc: cint, args: ptr UncheckedArray[cstring], env: ptr UncheckedArray[cstring]): int {.importc: "main".} | |
proc setup() : void {.exportC:"setup".} = | |
when defined(wasi): | |
echo "_initialized" | |
discard initialize(0,nil,nil) | |
var | |
tcb : Table[int, proc () : void] | |
echo "begin" | |
tcb[1] = proc() = discard | |
var notused = table.mGetOrPut("hmm" , tcb ) | |
echo "end" | |
# CRASH HERE | |
when not defined(wasi): | |
setup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment