console.log/info/warn/error/debug silently truncate the line at an embedded NUL (U+0000)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 82/100
調査の方向性
builtins/web/console.cppから始め、console_outがフォーマット済みの行をbuiltin_impl_console_logに渡す方法をたどります。次に、他のコンソールメソッドとembedding/embedding.cppにあるComponentizeJSのオーバーライドを確認します。埋め込みNULを含む文字列全体を、フックと出力経路を通じて保持します。再現コードで、影響を受ける各メソッドについてNUL以降の内容がすべて出力されることを確認します。
索引モデルが issue の本文から書いたものです。
説明
Summary
If any argument to a console method contains U+0000, everything after it on that line is lost, including later
arguments. No error is raised. JS strings may contain U+0000 (for example, output from TextDecoder, binary
protocols or String.fromCharCode loops), so debug output silently drops data.
Environment
- StarlingMonkey v0.4.0 release
starling.wasm, wasmtime 50.0.1,--legacy-script. - The code involved is unchanged on
main(54b3329b). - Also seen in a
@bytecodealliance/componentize-js0.23.0 component. - Checked on 2026-11-03. Reference: node v26.13.0.
Reproduction
console.log("a\u0000b", "c");
console.log("x", "a\u0000b", "c");
console.error(["a\u0000b"]);
console.log("next line is fine");
| StarlingMonkey | node | |
|---|---|---|
| line 1 | Log: a |
a\0b c |
| line 2 | Log: x a |
x a\0b c |
| line 3 | Error: [ "a |
[ 'a\x00b' ] |
| line 4 | Log: next line is fine |
next line is fine |
Expected
The whole line is printed (with the NUL written as-is or escaped). The Console Standard
leaves the output format to the implementation, but nothing allows dropping part of the data.
Cause
console_out in builtins/web/console.cpp builds the complete line in a std::string (NULs included), then calls
builtin_impl_console_log(log_ty, fullLogLine.c_str());
and builtin_impl_console_log(Console::LogType, const char *msg) prints msg as a C string, which stops at the first
'\0'. The other console methods (assert, count, time*, group, trace) pass .c_str() the same way.
Suggested fix
Change the hook to take a length-carrying string, e.g. builtin_impl_console_log(Console::LogType, std::string_view msg),
and print it with std::println(stdout, "{}: {}", prefix, msg) (a string_view argument keeps embedded NULs) or
fwrite(msg.data(), 1, msg.size(), stdout). Since builtin_impl_console_log is a weak symbol that embedders override,
ComponentizeJS's override in embedding/embedding.cpp (which prints with fprintf(stdout, "%s\n", msg)) needs the same
signature change.
- 主要言語
- C
- スター
- 297
- フォーク
- 64
- 平均マージ
- 2日 2時間
- マージ済み PR(30日)
- 19
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
bytecodealliance/StarlingMonkey のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
bytecodealliance/StarlingMonkey#355 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 1〜2日 初心者へのやさしさ 68/100
bytecodealliance/StarlingMonkey#358 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
bytecodealliance/StarlingMonkey#357 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
bytecodealliance/StarlingMonkey#356 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 44/100
bytecodealliance/StarlingMonkey#354 ·
メンテナーはふだん 1 日以内に返信
bytecodealliance/StarlingMonkey の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
contrib/ivorysql_ora/src/builtin_packages/utl_file/utl_file.c:517 - FCOPY destroys a file when source and destination are the same対応中かも @Metastarx が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
ly05010419/MacNativeGames#1848 ·
メンテナーはふだん 1 日以内に返信
-
libc++ test-suite
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
llvm/llvm-project#239851 ·
メンテナーはふだん 1 日以内に返信