Repository navigation
Release v5.7.0: safe field iterators and const reads - #349
Merged
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
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.
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
CSVFieldvalues 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 sourceCSVRowcannot 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 byget<T>()reuses the cached classification. Custom decimal interpretation remains non-const. Const DataFrame-cell reads delegate directly withoutconst_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. Mutableauto& fieldbindings must migrate toconst auto& fieldorauto 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
std::expectedconversion.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.