Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid running into infinite loops when recovering from Reader errors #213

Merged

Conversation

Ten0
Copy link
Contributor

@Ten0 Ten0 commented Nov 2, 2020

Resolves #207

When reading and parsing a record fails, it's correct behavior in most cases to keep on trying to read and parse the next record.

However when the Error is caused by failing to read from the underlying impl Read, the next read would almost always fail with the exact same error.
In that scenario, reading from the underlying impl Read should not be attempted when trying to extract the next record, as this may lead to infinite loops.
Instead, the Reader will behave in the same way as if an end-of-file had been reached.

Resolves BurntSushi#207

When reading and parsing a record fails, it's correct behavior in most cases to keep on trying to read and parse the next record.

However when the Error is caused by failing to read from the underlying `impl Read`, the next read would almost always fail with the exact same error.
In that scenario, reading from the underlying `impl Read` should not be attempted when trying to extract the next record, as this may lead to infinite loops.
Instead, the `Reader` will behave in the same way as if an end-of-file had been reached.
@Ten0 Ten0 force-pushed the avoid-infinite-loops-on-io-errors branch from 86e01ec to 74480e4 Compare November 2, 2020 20:52
Copy link
Owner

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work! I love the comments and the way you implemented this. Great job.

One small nit: could you please make sure all lines are wrapped to 79 columns (inclusive)? rustfmt does this for code but not for comments.

Copy link
Owner

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@BurntSushi BurntSushi merged commit d1a69a0 into BurntSushi:master Nov 3, 2020
@BurntSushi
Copy link
Owner

This PR is on crates.io in csv 1.1.4.

@Ten0 Ten0 deleted the avoid-infinite-loops-on-io-errors branch November 3, 2020 17:09
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.

Recovering from CSV read errors leads to infinite loops when caused by IO errors
2 participants