C++, no exceptions, and OOM in `operator new`
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- cpp, wasm
調査の方向性
提供された C++ の例、clang++ コマンド、wasmtime の呼び出しで失敗を再現します。まず -fno-exceptions 下での operator new と __cxa_throw との相互作用を追跡し、次に WebAssembly に対する標準準拠の失敗動作を決定します。OOM ケースが無限ループしなくなり、制限されたメモリの例を対象とするリグレッションテストがあれば完了です。
索引モデルが issue の本文から書いたものです。
説明
This example program is intended to allocate 4 wasm pages of memory:
#include <vector>
#include <stdio.h>
int main() {
std::vector<int> v;
for (int i = 0; i < 65536; i++) {
v.push_back(4);
}
}
This can be compiled to have a max wasm memory size of 2 pages, though, which will cause the program to OOM at runtime:
$ clang++ foo.cpp -o foo.wasm -O2 -Wl,--stack-first,--max-memory=131072 -fno-exceptions
which produces foo.wasm.gz.
When run:
$ wasmtime run ./foo.wasm
this program will (currently for me) infinite loop.
The issue seems to be that when compiled with -fno-exceptions, which I believe is currently required of C++ code compiled with wasi-libc to wasm since __cxa_throw isn't otherwise defined, then the operator new operator is defined to return NULL for failed allocations. For a native platform this is fine because it probably faults quickly when accessing this address. For Wasm, however, this is a valid address so the program keeps going.
This was, for me, an unfortunately slow way for me to discover that the original program I was working with was OOM-ing and needed a --max-memory argument to be passed that was larger than the base. I'm not sure how best to improve this, though, since I suspect aborting on failure would not be spec-compliant with C++.
- 主要言語
- 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
-
`sha256()` returns a wrong hash when libsql-ffi is built with gcc 11 or later対応中かも @colinhacks が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
tursodatabase/libsql#2333 ·
メンテナーはふだん 11 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
OpenPrinting/cups#1826 ·
メンテナーはふだん 1 日以内に返信
-
Backport to 3.0 advertises a suffix that does not exist対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
389ds/389-ds-base#8152 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
RetroAchievements/rcheevos#580 · コメント 1 件 ·
メンテナーはふだん 5 日以内に返信