fermyon / spin-dotnet-sdk

Apache License 2.0
43 stars 11 forks source link

<unknown>!__wasm_export_spin_http_handle_http_request #41

Open tpmccallum opened 2 years ago

tpmccallum commented 2 years ago

I am trying out HTTP requests. Specifically accepting form requests into the .NET Spin application, and processing them like this:

var myValue = ctx.Request.Form["theValueFromMyRequest"].ToString();

The code builds 100% No errors and 0 warnings, but I get the following error when making a request into the .NET Spin Application.

2022-11-02T04:09:29.201278Z ERROR spin_http_engine: Error processing request: wasm trap: indirect call type mismatch
wasm backtrace:
    0: 0xbb974 - do_icall
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/mini/interp/interp.c:2258:20
    1: 0xb8019 - do_icall_wrapper
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/mini/interp/interp.c:2362:3
    2: 0x6261e - interp_exec_method
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/mini/interp/interp.c:3849:4
    3: 0x5e4a2 - interp_runtime_invoke
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/mini/interp/interp.c:2117:2
    4: 0x36765d - mono_jit_runtime_invoke
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/mini/mini-runtime.c:3357:10
    5: 0x213a10 - do_runtime_invoke
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/metadata/object.c:2416:11
    6: 0x2156f9 - mono_runtime_try_invoke
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/metadata/object.c:2525:9
    7: 0x214434 - mono_runtime_class_init_full
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/metadata/object.c:533:3
    8: 0x40294 - mono_interp_transform_method
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/mini/interp/transform.c:9645:3
    9: 0xb6a95 - do_transform_method
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/mini/interp/interp.c:2725:2
   10: 0xae3fa - method_entry
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/mini/interp/interp.c:3470:23
              - interp_exec_method
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/mini/interp/interp.c:4004:8
   11: 0x5e4a2 - interp_runtime_invoke
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/mini/interp/interp.c:2117:2
   12: 0x36765d - mono_jit_runtime_invoke
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/mini/mini-runtime.c:3357:10
   13: 0x213a10 - do_runtime_invoke
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/metadata/object.c:2416:11
   14: 0x2156f9 - mono_runtime_try_invoke
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/metadata/object.c:2525:9
   15: 0x214434 - mono_runtime_class_init_full
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/metadata/object.c:533:3
   16: 0x40294 - mono_interp_transform_method
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/mini/interp/transform.c:9645:3
   17: 0xb6a95 - do_transform_method
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/mini/interp/interp.c:2725:2
   18: 0xae3fa - method_entry
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/mini/interp/interp.c:3470:23
              - interp_exec_method
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/mini/interp/interp.c:4004:8
   19: 0x5e4a2 - interp_runtime_invoke
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/mini/interp/interp.c:2117:2
   20: 0x36765d - mono_jit_runtime_invoke
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/mini/mini-runtime.c:3357:10
   21: 0x213a10 - do_runtime_invoke
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/metadata/object.c:2416:11
   22: 0x2156f9 - mono_runtime_try_invoke
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/metadata/object.c:2525:9
   23: 0x214434 - mono_runtime_class_init_full
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/metadata/object.c:533:3
   24: 0xb9c90 - do_init_vtable
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/mini/interp/interp.c:3343:2
   25: 0x88154 - interp_exec_method
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/mini/interp/interp.c:5763:31
   26: 0x5e4a2 - interp_runtime_invoke
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/mini/interp/interp.c:2117:2
   27: 0x36765d - mono_jit_runtime_invoke
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/mini/mini-runtime.c:3357:10
   28: 0x213a10 - do_runtime_invoke
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/metadata/object.c:2416:11
   29: 0x2156f9 - mono_runtime_try_invoke
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/metadata/object.c:2525:9
   30: 0x214434 - mono_runtime_class_init_full
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/metadata/object.c:533:3
   31: 0xb9c90 - do_init_vtable
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/mini/interp/interp.c:3343:2
   32: 0x88154 - interp_exec_method
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/mini/interp/interp.c:5763:31
   33: 0x5e4a2 - interp_runtime_invoke
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/mini/interp/interp.c:2117:2
   34: 0x36765d - mono_jit_runtime_invoke
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/mini/mini-runtime.c:3357:10
   35: 0x213a10 - do_runtime_invoke
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/metadata/object.c:2416:11
   36: 0x2156f9 - mono_runtime_try_invoke
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/metadata/object.c:2525:9
   37: 0x21ed90 - mono_runtime_invoke
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/mono/metadata/object.c:2465:9
   38: 0xe9fb8 - mono_wasm_invoke_method_ref
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/wasi/mono-wasi-driver/driver.c:562:17
   39: 0xea1dd - mono_wasm_invoke_method
                    at /home/runner/work/dotnet-wasi-sdk/dotnet-wasi-sdk/modules/runtime/src/mono/wasi/mono-wasi-driver/driver.c:581:2
   40: 0x4092ed - <unknown>!call_clr_request_handler
   41: 0x40949c - <unknown>!process_http_request
   42: 0x409c82 - <unknown>!spin_http_handle_http_request
   43: 0x40a8e4 - <unknown>!__wasm_export_spin_http_handle_http_request
itowlson commented 2 years ago

Does setting UseWizer to false make any difference? There are a couple of things I know can cause this ugly issue, though I don't know why:

  1. Some exception scenarios
  2. Some internal static initialisation scenarios, which can be triggered with Wizer

Unfortunately I don't yet have a reliable sense for what these scenarios are, or why they manifest as this Wasm trap. Sorry, I know the utter opaqueness of the error makes it doubly frustrating!