Skip to content

bufread::generic::Decoder: don't reinitialize on reader EOF#148

Closed
eeeeeta wants to merge 3 commits intoNullus157:prīmumfrom
eeeeeta:no-read-after-eof
Closed

bufread::generic::Decoder: don't reinitialize on reader EOF#148
eeeeeta wants to merge 3 commits intoNullus157:prīmumfrom
eeeeeta:no-read-after-eof

Conversation

@eeeeeta
Copy link
Copy Markdown
Contributor

@eeeeeta eeeeeta commented May 12, 2022

If multiple_members is enabled, the bufread::generic::Decoder will
attempt to reinitialise the decoder inside State::Flushing, even if
the reason it entered that state was due to the reader returning an EOF.
This will result in an attempt to read past EOF, which is highly
undesirable to say the least.

To fix this, force multiple_members to false when we get an EOF
condition from the reader.

@eeeeeta eeeeeta force-pushed the no-read-after-eof branch from 0c6b4aa to c8bfeaf Compare May 12, 2022 17:36
@Nemo157
Copy link
Copy Markdown
Member

Nemo157 commented May 13, 2022

To understand the issue I added an additional test assertion that I believe covers what this is meant to fix: bd6f0ae. If that looks like what you saw you can cherry-pick it to your branch.

If `multiple_members` is enabled, the `bufread::generic::Decoder` will
attempt to reinitialise the decoder inside `State::Flushing`, even if
the reason it entered that state was due to the reader returning an EOF.
This will result in an attempt to read past EOF, which is highly
undesirable to say the least.

To fix this, force `multiple_members` to `false` when we get an EOF
condition from the reader.
@eeeeeta eeeeeta force-pushed the no-read-after-eof branch from c8bfeaf to 90f95e4 Compare May 13, 2022 10:39
@eeeeeta
Copy link
Copy Markdown
Contributor Author

eeeeeta commented May 13, 2022

@Nemo157 Yeah, that test looks good! Cherry-picked (and fixed the stupid compilation error :p)

Comment thread src/futures/bufread/generic/decoder.rs
@Nemo157 Nemo157 force-pushed the no-read-after-eof branch from 90f95e4 to e724673 Compare May 15, 2022 12:41
@Nemo157
Copy link
Copy Markdown
Member

Nemo157 commented May 15, 2022

I fixed my tests formatting and just applied the same change to all the implementations.

bors r+

bors Bot added a commit that referenced this pull request May 15, 2022
148: bufread::generic::Decoder: don't reinitialize on reader EOF r=Nemo157 a=eeeeeta

If `multiple_members` is enabled, the `bufread::generic::Decoder` will
attempt to reinitialise the decoder inside `State::Flushing`, even if
the reason it entered that state was due to the reader returning an EOF.
This will result in an attempt to read past EOF, which is highly
undesirable to say the least.

To fix this, force `multiple_members` to `false` when we get an EOF
condition from the reader.

Co-authored-by: eta <github@eta.st>
Co-authored-by: Wim Looman <git@nemo157.com>
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

Merging #148 (e724673) into prīmum (6104f83) will increase coverage by 0.52%.
The diff coverage is 95.78%.

@@            Coverage Diff             @@
##           prīmum     #148      +/-   ##
==========================================
+ Coverage   78.00%   78.52%   +0.52%     
==========================================
  Files          92       93       +1     
  Lines        2950     3041      +91     
==========================================
+ Hits         2301     2388      +87     
- Misses        649      653       +4     
Impacted Files Coverage Δ
tests/utils/mod.rs 100.00% <ø> (ø)
tests/utils/track_eof.rs 95.34% <95.34%> (ø)
src/futures/bufread/generic/decoder.rs 76.47% <100.00%> (+0.47%) ⬆️
src/tokio/bufread/generic/decoder.rs 75.92% <100.00%> (+0.45%) ⬆️
src/tokio_02/bufread/generic/decoder.rs 76.47% <100.00%> (+0.47%) ⬆️
src/tokio_03/bufread/generic/decoder.rs 75.92% <100.00%> (+0.45%) ⬆️
tests/utils/impls.rs 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6104f83...e724673. Read the comment docs.

@bors bors Bot closed this May 15, 2022
@eeeeeta
Copy link
Copy Markdown
Contributor Author

eeeeeta commented May 17, 2022

Thanks, @Nemo157! Would you mind cutting a new release and pushing it to crates.io? (we're using your crate in arti, and not having a git dependency would be nice!)

@eeeeeta eeeeeta deleted the no-read-after-eof branch May 17, 2022 13:20
@Nemo157
Copy link
Copy Markdown
Member

Nemo157 commented May 19, 2022

Published 0.3.14

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.

3 participants