C tests lose every result when the solution returns inf or NaN
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 76/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- c, javascript
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Rust
- Estrellas
- 177
- Forks
- 100
- Merge medio
- 1 d 8 h
- PR fusionados (30 d)
- 168
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de sysprog21/codetrial
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Python tests lose every result when the solution returns inf or NaNPosiblemente ocupada @shensyuan la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
sysprog21/codetrial#419 · 3 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Allow deselecting a chosen problem card by clicking it againPosiblemente ocupada @woohsin la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
sysprog21/codetrial#392 · 4 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Audio output can be confirmed without playing a test soundPosiblemente ocupada @ChenYingHan1121 la tomó hace 4 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
sysprog21/codetrial#359 · 5 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Add a Copy code button to the final reportPosiblemente ocupada @yansawu la tomó hace 4 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
sysprog21/codetrial#318 · 5 comentarios · 2 reacciones · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de sysprog21/codetrial
Issues similares
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 86/100
Los mantenedores suelen responder en 1 día
-
area:sim good first issue kind:feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 87/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
bitcoindevkit/bdk#2432 ·
Los mantenedores suelen responder en 3 días
-
The demo's interval button and chart legend keep the previous interval after an interval changeAbiertobug ui
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
userFRM/egui-charts#670 ·
Los mantenedores suelen responder en 1 día
-
docs good first issue
Dificultad 1/5 1-3 horas Aptitud para principiantes 84/100
Usenova-Labs/usenova-backend#35 ·
Los mantenedores suelen responder en 1 día