Skip to content

Fix mmread hang at EOF and BoundsError without trailing newline - #155

Open
ViralBShah wants to merge 1 commit into
masterfrom
vs/mmread-eof
Open

ViralBShah wants to merge 1 commit into
masterfrom
vs/mmread-eof

Conversation

@ViralBShah

Copy link
Copy Markdown
Member
  • Hang when the file ends before the size line: mmread and mmreadheader looped forever on a file containing only %%MatrixMarket matrix coordinate real general\n (or header plus % comments). They now throw Meta.ParseError and DataError respectively.
  • BoundsError without a trailing newline: %%MatrixMarket matrix coordinate real general\n2 2 1\n1 1 1.5 (no final \n) threw BoundsError: attempt to access 7-element Vector{UInt8} at index [8]. The same happened for integer and dense array files. _parsenext now treats the end of the buffer as the end of a number. This costs the same single comparison as the bounds check it replaces, and the mmapped buffer is not copied. Truncated data (fewer entries than declared) still throws BoundsError, as the existing tests expect.

Tests: I added regression tests to test/download.jl for coordinate (real, integer, pattern, complex) and array (real, integer, complex) files without a final newline, read both from files and from IOBuffers. The EOF cases run in a subprocess with a time limit, so a regression fails the test instead of hanging the suite. Pkg.test() passes on Julia 1.13.

🤖 Generated with Claude Code

- mmread and mmreadheader looped forever when the file ended before
  the size line (e.g. header only, or header plus comments). Now raise
  Meta.ParseError / DataError respectively.
- _parsenext read past the end of the buffer when the last number was
  not followed by whitespace. Treat end of buffer as a terminator inside
  a number; a missing number still raises BoundsError as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.91%. Comparing base (15ba435) to head (2eafb26).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #155      +/-   ##
==========================================
- Coverage   99.95%   99.91%   -0.05%     
==========================================
  Files          14       14              
  Lines        2387     2391       +4     
==========================================
+ Hits         2386     2389       +3     
- Misses          1        2       +1     

☔ 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.

This branch has not been deployed

No deployments
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.

1 participant