Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Redline: concurrent calls on one Instance silently return wrong values

オープン
#211 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java, wasm
領域
backend, compilers

調査の方向性

The issue is in the Redline backend's machine state, specifically the argsBuffer, callDepth, TRAP_CODE, and pendingException fields which are shared across threads. Start by examining the machine class and the host-call argument passing mechanism. The goal is to implement a thread-owner check on the outermost call to turn silent corruption into an error, as suggested. Look for the compiled calling convention to understand the context pointer.

索引モデルが issue の本文から書いたものです。

説明

Calling one native Instance from several threads returns wrong results with no error. The other backends do not do this: bytecode is correct, and the interpreter throws. Redline is the only one that answers quietly and wrongly.

Eight threads, 2000 calls each, on a shared instance of host-import-roundtrip.wat.wasm, whose callTakeI32 must always return -1:

Backend Failed calls Wrong results
Interpreter 16000 / 16000 0
Bytecode 0 / 16000 0
Redline (jffi) 5318 / 16000 783

Every Redline failure is TrapException: call stack exhausted. The 783 wrong results carried no error at all.

Cause

Per-call state lives in the machine, shared by every thread that enters it, rather than per thread.

  • argsBuffer is one buffer per machine, and host-call arguments pass through it, so one thread reads another's argument. takeI32 returns what it was handed, which is where the wrong values come from.
  • callDepth is an unsynchronised int, so outermostCall is missed, STACK_LIMIT is never re-anchored, and the stack guard fires against a stale limit.
  • TRAP_CODE and pendingException are shared too, so one thread can see and clear another's trap.

Instances are not thread-safe in general and this may simply be unsupported usage. It is filed for the failure mode rather than the usage: silent wrong answers instead of an error.

Suggested fix

Cheap, and worth doing on its own: compare-and-set an owner thread on the outermost call and throw if another thread is already inside. One atomic operation per outermost call, and it turns silent corruption into an actionable error, which is what the interpreter already does in effect.

Real: per-thread context and argument buffers, and a per-thread call depth. Bigger, because the context pointer is part of the compiled calling convention.

Note on #201

The watchdog fix does not cause this, but it does make it visible. Before it, the same probe gave 0 to 3 wrong results rather than 783: starting a thread per call serialised callers enough that most trapped before they could race. The data race is older than the watchdog work; what went away is the throttle that was hiding it.

🤖 Generated with Claude Code

主要言語
Java
スター
312
フォーク
24
平均マージ
1日 22時間
マージ済み PR(30日)
34

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

bytecodealliance/endive のほかの issue

bytecodealliance/endive の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。