WasmerSharp
WasmerSharp copied to clipboard
Getting export name on Desktop throws NullReferenceException depending on memory pages
using System;
using System.IO;
using WasmerSharp; // 0.7.0
public class Program
{
static void Main()
{
var mem = Memory.Create(minPages: 1, maxPages: 3); // run with maxPages of 3, then re-run with 2
var memImport = new Import("env", "mem", mem);
var wasm = File.ReadAllBytes("run_me.wasm");
var inst = new Instance(wasm, memImport);
foreach (var exp in inst.Exports)
{
Console.WriteLine("name: '{0}', kind: '{1}'", exp.Name, exp.Kind); // line 16
}
}
}
(module $my_module
(func $add4 (param $augend i32) (result i32)
local.get $augend
i32.const 4
i32.add)
(func $mul2 (param $multiplicand i32) (result i32)
local.get $multiplicand
i32.const 2
i32.mul)
(func $add4mul2 (param $v i32) (result i32)
local.get $v
call $add4
call $mul2)
(export "run_me" (func $add4mul2))
) ;; compile this to wasm, possibly via https://webassembly.github.io/wabt/demo/wat2wasm/
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
at System.Text.UTF8Encoding.GetCharCount (System.Byte* bytes, System.Int32 count, System.Text.DecoderNLS baseDecoder) [0x000ff] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-10/external/bockbuild/builds/mono-x64/external/corefx/src/Common/src/CoreLib/System/Text/UTF8Encoding.cs:1418
at System.String.CreateStringFromEncoding (System.Byte* bytes, System.Int32 byteLength, System.Text.Encoding encoding) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-10/external/bockbuild/builds/mono-x64/external/corefx/src/Common/src/CoreLib/System/String.cs:484
at System.Text.Encoding.GetString (System.Byte* bytes, System.Int32 byteCount) [0x00033] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-10/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/text/encoding.cs:1366
at WasmerSharp.WasmerByteArray.ToString () [0x0003f] in <d3625c313af7497fafb9fb2a435e5680>:0
at WasmerSharp.Export.get_Name () [0x0000c] in <d3625c313af7497fafb9fb2a435e5680>:0
at Program.Main () [0x00051] in wasm-in-dotnet-frmwrk/src/Program.cs:16
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
at System.Text.UTF8Encoding.GetCharCount (System.Byte* bytes, System.Int32 count, System.Text.DecoderNLS baseDecoder) [0x000ff] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-10/external/bockbuild/builds/mono-x64/external/corefx/src/Common/src/CoreLib/System/Text/UTF8Encoding.cs:1418
at System.String.CreateStringFromEncoding (System.Byte* bytes, System.Int32 byteLength, System.Text.Encoding encoding) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-10/external/bockbuild/builds/mono-x64/external/corefx/src/Common/src/CoreLib/System/String.cs:484
at System.Text.Encoding.GetString (System.Byte* bytes, System.Int32 byteCount) [0x00033] in /Users/builder/jenkins/workspace/build-package-osx-mono/2019-10/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/text/encoding.cs:1366
at WasmerSharp.WasmerByteArray.ToString () [0x0003f] in <d3625c313af7497fafb9fb2a435e5680>:0
at WasmerSharp.Export.get_Name () [0x0000c] in <d3625c313af7497fafb9fb2a435e5680>:0
at Program.Main () [0x00051] in wasm-in-dotnet-frmwrk/src/Program.cs:16
System Information
Mono JIT compiler version 6.8.0.123 (2019-10/1d0d939dc30 Thu Mar 12 23:19:08 EDT 2020)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS:
SIGSEGV: altstack
Notification: kqueue
Architecture: amd64
Disabled: none
Misc: softdebug
Interpreter: yes
LLVM: yes(610)
Suspend: hybrid
GC: sgen (concurrent by default)