fix(analyzer): tolerate malformed qpc_freq / truncated rows instead of crashing#19
Merged
Merged
Conversation
…f crashing
analyze.py parsed the qpc_freq header and every data row with bare int(), so a
non-integer "# qpc_freq=" value ("1e7", "10 MHz") or a half-flushed / short
data row (a crash mid-write) raised an uncaught ValueError/IndexError and
aborted the whole analyzer -- whereas the in-DLL C++ merge tolerates both
(StrictStoll falls back to the 10 MHz default; ReadFrameCsv/ReadGpuCsv skip a
row whose fields don't all extract). The two "equivalent" paths thus diverged
on corrupt input: one crashed, the other degraded.
Mirror the C++ behavior:
* qpc_freq: fall back to DEFAULT_QPC_FREQ (10 MHz) on a parse failure;
* data rows: skip via a _parse_int4 helper that returns None on
ValueError/IndexError, with a stderr count of how many were dropped.
The loud header-mismatch guard (wrong column header => SystemExit) is kept --
that catches "you passed the merged CSV by mistake", a different case.
Tests: a malformed qpc_freq header and a truncated data row now both produce
output (rc 0) instead of a traceback; 19/19 pass locally.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Finding #8 (code review): analyzer crashes where the C++ merge degrades
analyze.pyparsed theqpc_freqheader and every data row with bareint(). So a non-integer# qpc_freq=value (1e7,10 MHz) or a half-flushed / short data row (a crash mid-write) raised an uncaughtValueError/IndexErrorand aborted the whole analyzer — whereas the in-DLL C++ merge tolerates both (StrictStollfalls back to the 10 MHz default;ReadFrameCsv/ReadGpuCsvskip a row whose four fields don't all extract). The two documented-equivalent paths thus diverged on corrupt input: one crashes, the other degrades.Fix — mirror the C++ behavior
qpc_freq: fall back toDEFAULT_QPC_FREQ(10 MHz) on a parse failure (matchesStrictStoll)._parse_int4helper that returnsNoneonValueError/IndexError, with a stderr count of how many were dropped (matches the C++ row-skip).The loud header-mismatch guard (wrong column header →
SystemExit) is kept — that catches "you passed the merged CSV by mistake", a different, deliberate case.Verification (ran locally)
Two new tests — a malformed
qpc_freqheader and a truncated 3-field data row — now both produce output (rc 0) instead of a traceback, with the valid frames still merged:CI also runs this suite. No lines >99 cols.
🤖 Generated with Claude Code