Skip to content

Release loose-parser scanner bookkeeping when shift returns - #373

Closed
OskarEichler wants to merge 1 commit into
ruby:mainfrom
OskarEichler:codex/csv-scanner-keeps
Closed

OskarEichler wants to merge 1 commit into
ruby:mainfrom
OskarEichler:codex/csv-scanner-keeps

Conversation

@OskarEichler

Copy link
Copy Markdown
Contributor

Summary

Ensure the loose parser releases its current scanner keep when a caller exits through shift or an early block return. Skip that cleanup after transferring ownership to the robust parser.

Reproduction

After 10,000 calls to CSV.new("a,b\n" * 10_000).shift on the same CSV object, the release retains 10,000 scanner positions. The removal of the persistent enumerator in #363 exposed the missing non-local-return cleanup.

Verification

1,211 focused checks pass in each parser mode, including incremental line access, quoting transitions, headers and alternate separators. The repeated 10,000-shift reproduction retains zero positions with this patch rather than 10,000.

This isolated patch passes the unchanged upstream suite in both normal and CSV_PARSER_SCANNER_TEST=yes modes: 527 tests / 4,050 assertions in each mode, zero failures/errors. Commands use Ruby 4.0.6 through rbenv (bundle exec ruby run-test.rb). Syntax and git diff --check pass. The combined release-based consumer branch also passes gem build and rake warning:error rdoc.

No tests were added or changed, per the requesting project's explicit no-new-tests policy. Focused checks and measurements live outside this repository. The upstream no-RuboCop policy is respected. Verification was local on macOS/Ruby 4.0.6; the supported OS/Ruby matrix was not run locally. Current main and installed 3.3.6 share base commit 0873ab362d996f12796c3c3e8998b5be657a9b12; no unrelated changes are included.

Breaking changes and limitations

None. Parsed data, line access and incremental-reading behavior remain unchanged; unnecessary scanner bookkeeping is released.

@wtn

wtn commented Oct 30, 2026

Copy link
Copy Markdown

PR #379 fixes this problem, so I think this PR can be closed.

@kou kou closed this Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants