Learning WASM #12
November 15, 2023•859 words
分かってはいたけど、WASMの関数をホスト側からパラレルに実行したら死んだ。
毎回初期化するのは時間かかるから、プールを作って同時実行しないように制御しないとだな
thread 'thread 'thread 'thread 'thread 'thread '<unnamed><unnamed><unnamed>thread '<unnamed><unnamed><unnamed>' panicked at '' panicked at '' panicked at '' panicked at '0xabeedadce0 >= 0xabf167e7a0<unnamed>' panicked at '0xabeedadce0 >= 0xabf107eb900xabeedadce0 >= 0xabf14fe690', ', crates\runtime\src\traphandlers\backtrace.rs0x0 > 0xabf0d7ea60' panicked at '0xabeedadce0 >= 0xabf0efe9300x0 > 0xabf137eb90crates\runtime\src\traphandlers\backtrace.rs' panicked at '', ', ', :crates\runtime\src\traphandlers\backtrace.rs:0x0 > 0xabf11feba0:214crates\runtime\src\traphandlers\backtrace.rs214::13crates\runtime\src\traphandlers\backtrace.rs:', ', 21413
:note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
crates\runtime\src\traphandlers\backtrace.rscrates\runtime\src\traphandlers\backtrace.rs:
21413:
280::13:280280
13::
1313
thread '<unnamed>' panicked at '0xabf0d7e7b0 >= 0xabf0efeb40', crates\runtime\src\traphandlers\backtrace.rs:214:13
Unhandled exception. System.AggregateException: One or more errors occurred. (error while executing at wasm backtrace:
0: <unknown>!classlib_classlib_Class1__Read
1: 0x21e7d4 - <unknown>!malloc
note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information
Caused by:
wasm trap: call stack exhausted) (External component has thrown an exception.) (External component has thrown an exception.) (External component has thrown an exception.) (External component has thrown an exception.) (External component has thrown an exception.) (External component has thrown an exception.) (External component has thrown an exception.) (External component has thrown an exception.)
---> Wasmtime.TrapException: error while executing at wasm backtrace:
0: <unknown>!classlib_classlib_Class1__Read
1: 0x21e7d4 - <unknown>!malloc
note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information
Caused by:
wasm trap: call stack exhausted
at Wasmtime.NonTupleTypeFactory`1.Create(StoreContext storeContext, Store store, IntPtr trap, Span`1 values)
at Wasmtime.Function.InvokeWithReturn[TR](Span`1 argsAndResults, IReturnTypeFactory`1 factory, StoreContext storeContext)
at Wasmtime.Function.<>c__DisplayClass188_0`1.<WrapFunc>b__0()
at Program.<>c__DisplayClass0_0.<<Main>$>b__0(Int32 i) in C:\Users\iwate\works\dotnetwasm\wasmhost\Program.cs:line 36
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
at System.Threading.Tasks.TaskReplicator.Replica.Execute()
--- End of inner exception stack trace ---
at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction`1 action, ParallelOptions options, Boolean stopOnFirstFailure)
at System.Threading.Tasks.Parallel.ForWorker[TLocal,TInt](TInt fromInclusive, TInt toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Parallel.ForWorker[TLocal,TInt](TInt fromInclusive, TInt toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
at System.Threading.Tasks.Parallel.For(Int32 fromInclusive, Int32 toExclusive, Action`1 body)
at Program.<Main>$(String[] args) in C:\Users\iwate\works\dotnetwasm\wasmhost\Program.cs:line 33
---> (Inner Exception #1) System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
at Wasmtime.Function.Native.wasmtime_func_call_unchecked(IntPtr context, ExternFunc& func, ValueRaw* args_and_results, UIntPtr args_and_results_len, IntPtr& trap)
at Wasmtime.Function.Invoke(Span`1 argumentsAndResults, StoreContext storeContext)
at Wasmtime.Function.InvokeWithReturn[TR](Span`1 argsAndResults, IReturnTypeFactory`1 factory, StoreContext storeContext)
at Wasmtime.Function.<>c__DisplayClass188_0`1.<WrapFunc>b__0()
at Program.<>c__DisplayClass0_0.<<Main>$>b__0(Int32 i) in C:\Users\iwate\works\dotnetwasm\wasmhost\Program.cs:line 36
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
at System.Threading.Tasks.TaskReplicator.Replica.Execute()<---
---> (Inner Exception #2) System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
at Wasmtime.Function.Native.wasmtime_func_call_unchecked(IntPtr context, ExternFunc& func, ValueRaw* args_and_results, UIntPtr args_and_results_len, IntPtr& trap)
at Wasmtime.Function.Invoke(Span`1 argumentsAndResults, StoreContext storeContext)
at Wasmtime.Function.InvokeWithReturn[TR](Span`1 argsAndResults, IReturnTypeFactory`1 factory, StoreContext storeContext)
at Wasmtime.Function.<>c__DisplayClass188_0`1.<WrapFunc>b__0()
at Program.<>c__DisplayClass0_0.<<Main>$>b__0(Int32 i) in C:\Users\iwate\works\dotnetwasm\wasmhost\Program.cs:line 36
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
at System.Threading.Tasks.TaskReplicator.Replica.Execute()<---
---> (Inner Exception #3) System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
at Wasmtime.Function.Native.wasmtime_func_call_unchecked(IntPtr context, ExternFunc& func, ValueRaw* args_and_results, UIntPtr args_and_results_len, IntPtr& trap)
at Wasmtime.Function.Invoke(Span`1 argumentsAndResults, StoreContext storeContext)
at Wasmtime.Function.InvokeWithReturn[TR](Span`1 argsAndResults, IReturnTypeFactory`1 factory, StoreContext storeContext)
at Wasmtime.Function.<>c__DisplayClass188_0`1.<WrapFunc>b__0()
at Program.<>c__DisplayClass0_0.<<Main>$>b__0(Int32 i) in C:\Users\iwate\works\dotnetwasm\wasmhost\Program.cs:line 36
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
at System.Threading.Tasks.TaskReplicator.Replica.Execute()<---
---> (Inner Exception #4) System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
at Wasmtime.Function.Native.wasmtime_func_call_unchecked(IntPtr context, ExternFunc& func, ValueRaw* args_and_results, UIntPtr args_and_results_len, IntPtr& trap)
at Wasmtime.Function.Invoke(Span`1 argumentsAndResults, StoreContext storeContext)
at Wasmtime.Function.InvokeWithReturn[TR](Span`1 argsAndResults, IReturnTypeFactory`1 factory, StoreContext storeContext)
at Wasmtime.Function.<>c__DisplayClass188_0`1.<WrapFunc>b__0()
at Program.<>c__DisplayClass0_0.<<Main>$>b__0(Int32 i) in C:\Users\iwate\works\dotnetwasm\wasmhost\Program.cs:line 36
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
at System.Threading.Tasks.TaskReplicator.Replica.Execute()<---
---> (Inner Exception #5) System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
at Wasmtime.Function.Native.wasmtime_func_call_unchecked(IntPtr context, ExternFunc& func, ValueRaw* args_and_results, UIntPtr args_and_results_len, IntPtr& trap)
at Wasmtime.Function.Invoke(Span`1 argumentsAndResults, StoreContext storeContext)
at Wasmtime.Function.InvokeWithReturn[TR](Span`1 argsAndResults, IReturnTypeFactory`1 factory, StoreContext storeContext)
at Wasmtime.Function.<>c__DisplayClass188_0`1.<WrapFunc>b__0()
at Program.<>c__DisplayClass0_0.<<Main>$>b__0(Int32 i) in C:\Users\iwate\works\dotnetwasm\wasmhost\Program.cs:line 36
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
at System.Threading.Tasks.TaskReplicator.Replica.Execute()<---
---> (Inner Exception #6) System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
at Wasmtime.Function.Native.wasmtime_func_call_unchecked(IntPtr context, ExternFunc& func, ValueRaw* args_and_results, UIntPtr args_and_results_len, IntPtr& trap)
at Wasmtime.Function.Invoke(Span`1 argumentsAndResults, StoreContext storeContext)
at Wasmtime.Function.InvokeWithReturn[TR](Span`1 argsAndResults, IReturnTypeFactory`1 factory, StoreContext storeContext)
at Wasmtime.Function.<>c__DisplayClass188_0`1.<WrapFunc>b__0()
at Program.<>c__DisplayClass0_0.<<Main>$>b__0(Int32 i) in C:\Users\iwate\works\dotnetwasm\wasmhost\Program.cs:line 36
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
at System.Threading.Tasks.TaskReplicator.Replica.Execute()<---
---> (Inner Exception #7) System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
at Wasmtime.Function.Native.wasmtime_func_call_unchecked(IntPtr context, ExternFunc& func, ValueRaw* args_and_results, UIntPtr args_and_results_len, IntPtr& trap)
at Wasmtime.Function.Invoke(Span`1 argumentsAndResults, StoreContext storeContext)
at Wasmtime.Function.InvokeWithReturn[TR](Span`1 argsAndResults, IReturnTypeFactory`1 factory, StoreContext storeContext)
at Wasmtime.Function.<>c__DisplayClass188_0`1.<WrapFunc>b__0()
at Program.<>c__DisplayClass0_0.<<Main>$>b__0(Int32 i) in C:\Users\iwate\works\dotnetwasm\wasmhost\Program.cs:line 36
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
at System.Threading.Tasks.TaskReplicator.Replica.Execute()<---
---> (Inner Exception #8) System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
at Wasmtime.Function.Native.wasmtime_func_call_unchecked(IntPtr context, ExternFunc& func, ValueRaw* args_and_results, UIntPtr args_and_results_len, IntPtr& trap)
at Wasmtime.Function.Invoke(Span`1 argumentsAndResults, StoreContext storeContext)
at Wasmtime.Function.InvokeWithReturn[TR](Span`1 argsAndResults, IReturnTypeFactory`1 factory, StoreContext storeContext)
at Wasmtime.Function.<>c__DisplayClass188_0`1.<WrapFunc>b__0()
at Program.<>c__DisplayClass0_0.<<Main>$>b__0(Int32 i) in C:\Users\iwate\works\dotnetwasm\wasmhost\Program.cs:line 36
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
at System.Threading.Tasks.TaskReplicator.Replica.Execute()<---