C tests lose every result when the solution returns inf or NaN
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 76/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- c, javascript
調査の方向性
Start in web/compiler-explorer.js at cPrintActual and json_double_array, then read parseCompilerResults to see how invalid JSON loses the whole result set. Run the existing harness tests in tests/browser/compiler-explorer.test.js and inspect the toolchain harnesses section. Done means the C harness emits parseable JSON for non-finite doubles and the regression test confirms unaffected cases retain their results.
索引モデルが issue の本文から書いたものです。
説明
Observed behavior
When a C solution returns inf or NaN for any test case of a problem that returns double or double[], the whole run is reported as a setup error and every case result is lost, including the passing ones. The test panel shows "Couldn't run your code" and "The run produced no JSON results." instead of a per-case table. This is the C counterpart of #419, which covers the Python runner.
The same solution in C++ fails only the affected cases, because C++ toJson(double) (web/compiler-explorer.js:553) and Java json(double) (:717, :760) write null for a non-finite value.
Expected behavior
Only the cases that returned a non-finite number fail, and the other cases keep their results, as in C++ and Java. For the solution below that is 3 passing cases and 3 failing ones ("negative exponent", "minimum integer exponent reciprocal path" and "cubed negative exponent").
Reproduction
- Start an interview on Compound Growth Factor and switch the editor to C.
- Replace the starter with this solution, which leaves negative exponents unfinished and returns
inffor them:
double growthOverPeriods(double x, int n) {
if (n < 0) return 1.0 / 0.0;
double result = 1.0;
for (int i = 0; i < n; i++) result *= x;
return result;
}
- Click Run tests. The panel shows "Couldn't run your code" and "The run produced no JSON results."
- Switch to C++, wrap the same function in
class Solution { public: ... };and click Run tests: 3 cases pass and 3 fail.
Without a browser, the same result can be seen by building the C harness with generateHarness("c", ...) from web/compiler-explorer.js for web/judges/compound-growth-factor.json and the solution above, compiling it with cc -std=c17 and running it. Its output is:
{"results":[{"actual":1024,"timeMs":0.000},{"actual":9.261000000000001,"timeMs":0.000},{"actual":inf,"timeMs":0.000},{"actual":1,"timeMs":0.000},{"actual":inf,"timeMs":0.000},{"actual":inf,"timeMs":0.000}]}
Passing that string to parseCompilerResults returns { setupError: "The run produced no JSON results." }. A NaN is printed as -nan on glibc, which fails the same way.
CodeTrial version
codetrial 0.1.0 (2961519)
Environment
OS: Windows 11 with WSL2 (server in WSL, browser on Windows)
Browser: Google Chrome 156.0.8078.47
Access: local server at http://127.0.0.1:3100/
Language: C (C++ as the control)
Problem: Compound Growth Factor
Initial analysis
On main (2961519), cPrintActual prints a double return with a bare printf("%.17g", ...) (web/compiler-explorer.js:488), and json_double_array (:395) uses the same format for each element. Neither checks isfinite, so a non-finite value is written as inf or -nan, which are not JSON. All cases are printed as one {"results":[...]} object, so parseCompilerResults (:200) cannot parse any of it and falls back to the setup error at :215. The existing test generated harnesses emit JSON for control characters and non-finite doubles (tests/browser/compiler-explorer.test.js:169) checks only the C++ and Java sources, so the C gap is not covered.
Affected problems: Compound Growth Factor and Twin Sensor Midpoint Reading (double), and Lab Unit Converter (double[]). #425 routes list<double> to json_double_array, so Hop Depth Signal Means will reach the same printer once it lands.
Proposed change: add a C helper that writes null for a non-finite double and use it in both the double branch and json_double_array, matching C++ and Java. Add a case under toolchain harnesses in tests/browser/compiler-explorer.test.js that compiles the C harness with cc for Compound Growth Factor with a solution returning inf and NaN, and fails before the change with 3 passing and 3 failing cases expected.
Sanitized evidence
Public data confirmation
- I removed credentials, session tokens, candidate recordings, and personal interview content from this public report.
- 主要言語
- Rust
- スター
- 177
- フォーク
- 100
- 平均マージ
- 1日 11時間
- マージ済み PR(30日)
- 182
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
sysprog21/codetrial のほかの issue
-
Selecting a pen color leaves Example drawing in eraser mode対応中かも @Aa99841 が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
sysprog21/codetrial#437 · コメント 4 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Python tests lose every result when the solution returns inf or NaN対応中かも @shensyuan が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
sysprog21/codetrial#419 · コメント 3 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Allow deselecting a chosen problem card by clicking it again対応中かも @woohsin が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
sysprog21/codetrial#392 · コメント 4 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Audio output can be confirmed without playing a test sound対応中かも @ChenYingHan1121 が 5 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
sysprog21/codetrial#359 · コメント 5 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Add a Copy code button to the final report対応中かも @yansawu が 5 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
sysprog21/codetrial#318 · コメント 6 件 · リアクション 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
sysprog21/codetrial の issue をすべて見る
似ている issue
-
checkpoint/verify/rebuild_indexes on a thread holding a WriteTransaction deadlock instead of INT-001オープンbug known-issue
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
project-minigraf/minigraf#734 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 4 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
bug CLI documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
openai/codex#56630 · コメント 3 件 · リアクション 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
DayuanJiang/PecoFence#139 ·
メンテナーはふだん 1 日以内に返信