Can we support stackful coroutines / fibers?

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

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
20/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
rust

調査の方向性

Start with the issue and its linked LLVM discussion about TLS variables, then review how Rust currently handles thread-local storage and stack switching. No implementation entry point or test is named; the work would need an agreed support design and a defined way to validate that stackful coroutines avoid the described unsoundness.

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

説明

A-missing

Rust has no official support for using stackful coroutines (such as the fiber APIs on Windows, or doing the same with inline asm stack switching on Linux) -- but people do it anyway so there's clearly a demand (Cc @Amanieu). However, this means that the addresses of TLS variables can change basically any time, which is unsound as LLVM assumes the opposite (https://github.com/llvm/llvm-project/issues/98479). Cc @nikic

So, right now doing stack switching or using the Windows fiber API in Rust is pretty much UB (at least if the code also uses thread-local variables, which std does so that's basically a given). There's little we can do about that until LLVM has a way of avoiding that UB, but it seems worth tracking this on the Rust side and maybe brainstorming ideas about how stackful coroutines could be supported without pessimizing all optimizations everywhere: the fundamental issue is that any function call might change the thread this function runs on, so all thread-local variables have to be re-loaded, but most function calls don't actually do that so usually this is a pointless pessimization.

主要言語
言語のデータがありません
スター
760
フォーク
68
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

rust-lang/unsafe-code-guidelines のほかの issue

rust-lang/unsafe-code-guidelines の issue をすべて見る

似ている issue

Compilers の issue をもっと見る

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

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