dotnet / dotnet-wasi-sdk

An SDK for building .NET projects as standalone WASI-compliant modules
MIT License
283 stars 12 forks source link

Garbage Collection throws #32

Open HermanSchoenfeld opened 6 months ago

HermanSchoenfeld commented 6 months ago

After attempting to figure out why my prototype was throwing, it looks like garbage collection is broken in Wasi.Sdk both when called by the runtime in the oridinary course of execution (what was happening my case) but also when explicitly called (as below code). Can you please fix this ASAP as it's kind of fundamentally important for any use-case?

Error

[wasm_trace_logger] * Assertion at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/metadata/sgen-stw.c:77, condition `info->client_info.stack_start >= info->client_info.info.stack_start_limit && info->client_info.stack_start < info->client_info.info.stack_end' not met

Repo https://github.com/HermanSchoenfeld/WasiSdkBug

Code

namespace ConsoleApp1
{
    internal class Program
    {
        static void Main(string[] args) {
            GC.Collect();
        }
    }
}

Environment .NET 8, .NET 7 Wasi.Sdk 0.1.4-preview.10020 and 0.1.1 wasmtime-cli 19.0.2 (040ec9209 2024-04-11)

HermanSchoenfeld commented 6 months ago

I've added a repo to reproduce this bug. It's extremely basic and this should work. I think there's something wrong with the targets definition.

https://github.com/HermanSchoenfeld/WasiSdkBug

kpreisser commented 2 months ago

See #12. It seems this issue has been resolved with .NET 8.0 when using the wasi-wasm workload/RID, which obsoletes the Wasi.Sdk.