Multiple C# Threads calling WASM Module
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- csharp, wasm
- 領域
- backend, testing-qa
調査の方向性
まず、2つのスレッドを使ったC#ユニットテストのシナリオを再現し、次に1つのスレッドの場合およびC#のlockケースと比較します。TryVerifyに示されている共有WASM呼び出し、文字列の割り当て、メモリ読み取り、_Free呼び出しを追跡します。これにより、同時呼び出しでサポートされる動作を確立し、検証済みの解決策または明示的な制限を提示できるようにします。
索引モデルが issue の本文から書いたものです。
説明
I have tried to run a WASM module from a C# unit test where there are 2 threads calling the module in a loop. This dies with one of the threads ending in with the following exception
wasm trap: call stack exhausted
Here is logged output from the Test where
- [n] is the thread number
- Count is the iterations for that thread
- Error Count is whether the result was in error (as I was checking for race conditions)
- Exception is the C# exception that was caught from the WASM method Invoke
Debug Trace:
[0] Count: 0 ErrorCount: 0 Exception: error while executing at wasm backtrace:
0: <unknown>!<wasm function 37>
1: 0xb25 - <unknown>!<wasm function 14>
2: 0x47d8 - <unknown>!<wasm function 37>
Caused by:
wasm trap: call stack exhausted
[1] Count: 89498 ErrorCount: 0 Exception:
It is like the WASM module method is being called OK by one thread while the other thread is looks to be calling the method but never leaving it and the stack eventually blew up??
If I run this as 1 thread OR put a C# Lock {} block around the WASM method call, then it all runs fine, and I have called the method for over 5,000,000 iterations without an issue.
The WASM module was written in C and and generated using Emscripten. The method takes in two string (pointers) and a an Int64 and returns a string (pointer).
The memory is being Free'ed.
C method
char* TryVerify(char* token, char* originHeader, uint64_t serverUtcUnixNowMilliseconds)
C# call
object lockObject = new object();
public bool TryVerify(string token, string originHeader, out TokenData tokenData)
{
//lock (lockObject)
//{
var serverUtcUnixNowMilliseconds = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeMilliseconds();
int inPtrToken = WriteStringToUTF8(token);
int inPtrOriginHeader = WriteStringToUTF8(originHeader);
int outPtr = _TryVerify.Invoke(inPtrToken, inPtrOriginHeader, serverUtcUnixNowMilliseconds);
var json = Memory.ReadNullTerminatedString(outPtr);
_Free(outPtr);
tokenData = System.Text.Json.JsonSerializer.Deserialize<TokenData>(json, new JsonSerializerOptions() { PropertyNameCaseInsensitive = true }) ?? throw new Exception("Failed to deserialize token data from wasm");
if (tokenData == null)
{
tokenData = new TokenData();
}
return tokenData.IsOk;
// }
}
- 主要言語
- C#
- スター
- 516
- フォーク
- 69
- 平均マージ
- 6時間 1分
- マージ済み PR(30日)
- 5
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
bytecodealliance/wasmtime-dotnet のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 42/100
bytecodealliance/wasmtime-dotnet#374 · コメント 2 件 ·
-
wasip3 supportオープン
難易度 5/5 1週間以上 初心者へのやさしさ 32/100
bytecodealliance/wasmtime-dotnet#350 · コメント 6 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
-
WasmGCオープン
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
bytecodealliance/wasmtime-dotnet#342 · コメント 8 件 ·
bytecodealliance/wasmtime-dotnet の issue をすべて見る
似ている issue
-
test
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
NethermindEth/nethermind#14274 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
area:frontend bug FE P3
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
klasolsson81/jobbliggaren#2023 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
shimat/opencvsharp#2154 ·
メンテナーはふだん 1 日以内に返信
-
subsystem: UI
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
Open-Systems-Pharmacology/PK-Sim#3812 ·
メンテナーはふだん 1 日以内に返信