Skip to content

reject non-finite cost values in json parser - #113

Merged
jrfonseca merged 1 commit into
jrfonseca:mainfrom
nvxbug:json-nonfinite-cost
Jul 7, 2026
Merged

jrfonseca merged 1 commit into
jrfonseca:mainfrom
nvxbug:json-nonfinite-cost

Conversation

@nvxbug

@nvxbug nvxbug commented Jul 1, 2026

Copy link
Copy Markdown
Contributor
ValueError: cannot convert float NaN to integer

A JSON profile whose cost is NaN or Infinity reaches this, since json.load accepts those tokens as an extension even though schema.json defines costs as finite numbers. The non-finite value lands in the per-function and global SAMPLES totals, so one crafted event poisons the denominator of every ratio (other functions collapse to 0%) and NaN then propagates into color() and aborts the run. Reject the tokens with a parse_constant callback so the profile is refused at load instead.

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.88%. Comparing base (0896778) to head (9fe37b7).

Files with missing lines Patch % Lines
gprof2dot.py 50.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #113      +/-   ##
==========================================
- Coverage   85.01%   84.88%   -0.13%     
==========================================
  Files           1        1              
  Lines        2329     2336       +7     
==========================================
+ Hits         1980     1983       +3     
- Misses        349      353       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jrfonseca

Copy link
Copy Markdown
Owner

Makes sense. Thanks.

@jrfonseca
jrfonseca merged commit 981d69c into jrfonseca:main Jul 7, 2026
3 of 5 checks passed
@nvxbug

nvxbug commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for taking this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants