Repository navigation
csv-parser v5.8.0
v5.8.0 replaces eof() with an unambiguous way to check for another row, fixes parser-worker races, makes empty-file behavior consistent, and adds continuous differential fuzzing.
These notes cover all changes since v5.7.1.
How this release came together
I ran three GPT-5.6 Sol agents at Ultra effort to independently:
- Audit the parser for memory errors.
- Look for thread races.
- Design and implement fuzzing for CI.
The memory audit found no confirmed memory-safety defects.
The thread-race investigation, run with Daybreak enabled, found and reproduced a potential race in CSVReader::eof(). A caller could query eof() at the same time the background parser was finishing the final source chunk and setting its internal EOF flag. The same investigation found that speculative-parsing diagnostics could be read while the worker was updating their counters.
The narrow fix for eof() would have been to make its internal flag atomic. That led me to question the point of the method itself. eof() answered whether the parser had reached the end of its input, but the question users were more likely to be asking was whether the CSV still had another row to read. Those are not always the same thing because parsed rows may remain queued after the source is exhausted.
It was better to remove the ambiguous API and replace it with one that directly answers the useful question.
The fuzzing work also paid off immediately. Differential replay found that a readable zero-byte file produced ordinary exhaustion through the stream backend but OpenFailed through the memory-mapped backend. That inconsistency is fixed in this release.
eof() replaced by row lookahead
C++ CSVReader::eof() and Python Reader.eof() have been removed.
Normal consuming loops should use read_row() or iteration:
while (reader.read_row(row)) {
// Process row.
}When a non-consuming check is actually needed, use has_next_row():
if (reader.has_next_row()) {
// Another logical row can be read.
}Exception-disabled and explicit-error code can use try_has_next_row():
csv::CSVError error;
if (reader.try_has_next_row(error)) {
// A row is available.
} else if (error) {
// Parsing failed.
} else {
// Ordinary exhaustion.
}Repeated lookahead calls do not consume the next returnable row. The check may block while parsing finishes and may skip physical records excluded by the configured variable-column policy.
The regular read_row() path remains unchanged. Only callers requesting lookahead pay for the synchronized queue-front copy.
CSVReader remains a single-consumer object. Lookahead is not intended to make concurrent user operations safe.
Thread-race fixes
The public EOF race is eliminated by keeping source exhaustion as a worker-owned internal detail.
speculative_diagnostics() now synchronizes updates and snapshots so callers cannot observe counters halfway through a merge.
Large regression tests exercise both the memory-mapped and stream paths while their background workers cross multiple parser windows.
See #353 for the original reports and ThreadSanitizer reproductions.
Empty files
Readable zero-byte files now behave consistently across parser backends: opening succeeds, and attempts to read a row report ordinary exhaustion.
Previously, native mapping APIs caused the memory-mapped path to report OpenFailed, even though the file existed and was readable. The differential fuzzer discovered this discrepancy.
Missing and unreadable files continue to report errors normally.
Continuous fuzzing
The repository now includes opt-in Clang/libFuzzer targets covering:
- Arbitrary stream parsing.
- Differential behavior between stream and memory-mapped parsing.
- Synchronous and threaded scheduling.
- Quotes, delimiters, newlines, NULs, and other syntax around parser-window boundaries.
Pull requests replay the committed regression corpus and run short ASan/UBSan campaigns. Longer nightly campaigns retain evolving corpora and upload crash artifacts and logs. Inputs are also replayed separately under TSan.
The harness was reviewed and strengthened before adoption so more parser configurations and boundary cases are reachable. Fuzz builds inherit the shipped library’s compile configuration rather than maintaining a separate approximation.
Ordinary builds are unaffected unless CSV_BUILD_FUZZERS is enabled.
Other changes
- Cleaned up the checked DataFrame-writing helpers introduced with the recent no-exceptions work. A complete frame now uses
try_write_frame(frame, error); row-named methods write individual rows.writer << frameremains the throwing convenience. - Updated generated-distribution tooling to
single_header1.3.1, including its Linux constant-evaluation fix. - Improved GCC coverage processing.
- Reworked the README and updated the no-exception and Python documentation.
- Bumped the C++ library and
fastpycsvpackage metadata to 5.8.0.
Changes since v5.7.1
- Differential fuzzing and empty-file handling (#354)
- Fuzzer strengthening (#355)
- Reader metadata synchronization and regression coverage (#356)
- v5.8.0 API and release changes (#357)
Full changelog: v5.7.1...v5.8.0