Skip to content

Release v5.7.0: safe field iterators and const reads - #349

Merged
vincentlaucsb merged 8 commits into
masterfrom
test/csvrow-reverse-iterator-lifetime
Oct 29, 2026
Merged

vincentlaucsb merged 8 commits into
masterfrom
test/csvrow-reverse-iterator-lifetime

Conversation

@vincentlaucsb

@vincentlaucsb vincentlaucsb commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

Field references owned by temporary iterator copies could dangle during reverse traversal. Forward iterator movement could also invalidate a saved field reference.

Forward and reverse field iterators now return short-lived CSVField values with independent lazy conversion caches. Navigation and wrapper creation require no heap allocation. Arrow syntax uses a temporary value-owning proxy. Iterators retain the original chunk and capture the original row span, so reusing or destroying the source CSVRow cannot redirect them.

Field queries and ordinary conversions are logically const. Only the derived type and numeric caches are mutable; reads preserve the field's text and interpretation. is_num() followed by get<T>() reuses the cached classification. Custom decimal interpretation remains non-const. Const DataFrame-cell reads delegate directly without const_cast.

README examples consistently use const auto& for read-only rows and fields. The row reference borrows the current row; the field reference extends the temporary field's lifetime through the loop body. Local value loops also remain supported. C++11–17 retain the legacy input category and the library's value-returning reverse iterator; C++20 concepts support random access and standard reverse adaptors. Mutable auto& field bindings must migrate to const auto& field or auto field. The design, lifetime, const-cache contract and migration are documented in the field-iteration and scalar-conversion guides and architecture guidance. The original README edits are included.

Validation

  • MSVC C++20 AddressSanitizer: 1,073 field/iterator assertions across 50 cases pass, including genuinely const fields, optional conversions, standard reverse adaptors, composed views, row reuse, quoted/trimmed fields, eager scalar slots, and conversion failures.
  • MSVC AddressSanitizer: const DataFrame-cell regression passes (15 assertions); standalone allocation/error consumer and writing suite pass.
  • 500,000-row chunk-transition lifetime regressions cover mmap and stream readers.
  • Standalone allocation regression verifies zero field-wrapper allocations during construction, navigation, const reads, arrow access, and conversion.
  • Compiler-disabled exception build: all 4 CTest suites pass, including reading, writing, DataFrames, and the standalone consumer.
  • MSVC C++23 standalone consumer passes, including const std::expected conversion.
  • Exact-standard consumers include const-read checks, constexpr text-view validation, and a compile-time check that decimal interpretation cannot change through const fields. Genuine C++11 and generated-header checks run in CI.
  • GitHub CI is running for the latest pushed revision.

Release

Prepare v5.7.0: the public C++ header and Python package metadata both declare 5.7.0. Release notes will highlight the field-reference migration and the legacy iterator-category change.

Dereferencing rbegin() copies a CSVField that std::reverse_iterator
frees inside operator* before the caller can read it. AddressSanitizer
reports that heap-use-after-free.
@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.04%. Comparing base (705ea5c) to head (2ee8aa3).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #349      +/-   ##
==========================================
+ Coverage   91.95%   92.04%   +0.08%     
==========================================
  Files          63       63              
  Lines        4538     4627      +89     
  Branches     1383     1379       -4     
==========================================
+ Hits         4173     4259      +86     
- Misses        106      108       +2     
- Partials      259      260       +1     
Flag Coverage Δ
cpp 91.96% <100.00%> (+0.09%) ⬆️
python 93.64% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

std::reverse_iterator::operator* dereferences a temporary base iterator.
CSVRow::iterator owns its CSVField, so that temporary freed the field
before the caller could read it. The reverse iterator now stores the
decremented iterator and returns a reference into that member.
@vincentlaucsb vincentlaucsb changed the title Add a regression for the CSVRow reverse-iterator lifetime Fix the CSVRow reverse-iterator use-after-free Oct 28, 2026
@vincentlaucsb vincentlaucsb changed the title Fix the CSVRow reverse-iterator use-after-free Return CSVRow iterator fields by value to fix lifetime bugs Oct 28, 2026
Comment thread include/internal/csv_row.cpp Fixed
@vincentlaucsb vincentlaucsb changed the title Return CSVRow iterator fields by value to fix lifetime bugs Return CSVRow fields by value with logically const reads Oct 29, 2026
@vincentlaucsb vincentlaucsb changed the title Return CSVRow fields by value with logically const reads Release v5.7.0: safe field iterators and const reads Oct 29, 2026
@vincentlaucsb
vincentlaucsb merged commit efd7274 into master Oct 29, 2026
49 checks passed
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