Data race or race condition during exiting/joining a thread
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 30/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- c, wasm
調査の方向性
libc-top-half/musl/src/thread/pthread_create.c から始め、特にレポートで引用されているスレッド数の終了パスとスタックの解放を確認してください。提供されている wasm32-wasi-threads の再現プログラムを wasmtime でビルドして実行し、その後、スレッドの管理状態と join/exit の動作をトレースしてください。ストレスプログラムが正常に完了し、危険なスタッククリーンアップなしで "ok!" と出力すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
This is a program which spawns N threads. Each thread will then, M times, spawn a thread and join the thread. This is intended to exercise concurrently spawning threads.
#include <pthread.h>
#include <stdio.h>
#include <assert.h>
#define N 10
#define M 10000
static void *another_child(void *arg) {
return arg;
}
static void* child(void *arg) {
pthread_t child;
for (int i = 0; i < M; i++) {
int rc = pthread_create(&child, NULL, another_child, NULL);
if (rc != 0)
perror("failed to create thread");
rc = pthread_join(child, NULL);
if (rc != 0)
perror("failed to join thread");
}
return arg;
}
int main() {
pthread_t children[N];
for (int i = 0; i < N; i++) {
int rc = pthread_create(&children[i], NULL, child, NULL);
if (rc != 0)
perror("failed to spawn thread");
}
for (int i = 0; i < N; i++) {
int rc = pthread_join(children[i], NULL);
if (rc != 0)
perror("failed to join thread");
}
printf("ok!\n");
}
This is then run with:
$ clang foo.c -o foo.wasm -O2 --target=wasm32-wasi-threads -pthread -Wl,--import-memory,--export-memory,--stack-first,-zstack-size=$((10 << 20)),--max-memory=$((3 << 30))
$ wasmtime run --wasi-modules experimental-wasi-threads --disable-cache --wasm-features threads -- ./foo.wasm
This will produce no output and exit with status zero, but not expectedly. The ok! is not printed at the end of the main function. The reason for this appears to be that this exit is reached because a thread confuses itself as the last remaining thread.
I did a bit of poking to see if this could be fixed. The __tl_lock() function, for example, is aliased to a dummy_0 in many files. I wasn't able to fix it, however.
While looking around in this file, however, I also noticed that free is used to deallocate a thread stack which I don't believe is correct because the thread stack is in use by the thread calling free, which means that after the memory has been deallocated some stack management may still be happening which may modify the free'd memory. I haven't run into this myself, though, and commenting out the free did not fix my issue above.
cc @abrown
- 主要言語
- C
- スター
- 1k
- フォーク
- 268
- 平均マージ
- 1日 3時間
- マージ済み PR(30日)
- 20
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
WebAssembly/wasi-libc のほかの issue
-
wasip2: enabling O_APPEND with fcntl reuses the old positional output stream and overwrites the fileオープン
難易度 3/5 1〜2日 初心者へのやさしさ 70/100
WebAssembly/wasi-libc#919 ·
メンテナーはふだん 1 日以内に返信
-
wasip2/wasip3: reads never see data appended to a file after reaching EOF対応中かも @libsmol が 25 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 61/100
WebAssembly/wasi-libc#889 ·
メンテナーはふだん 1 日以内に返信
-
Contradicting `SOL_TCP` and `SOL_UDP` definition for p1再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
WebAssembly/wasi-libc#855 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 55/100
WebAssembly/wasi-libc#815 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
WebAssembly/wasi-libc#809 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
WebAssembly/wasi-libc の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
389ds/389-ds-base#8152 ·
メンテナーはふだん 2 日以内に返信
-
meta:feature-request
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
mpv-player/mpv#18855 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
bug help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
メンテナーはふだん 1 日以内に返信
-
isolation2 lockmodes fails on cassert builds: extra AccessShareLock on partition root対応中かも @tuhaihe が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/cloudberry#2356 ·
メンテナーはふだん 2 日以内に返信