Skip to content

Fix Ref::new_slice_from_suffix()#506

Merged
joshlf merged 2 commits intogoogle:mainfrom
dmitryash:fix_new_slice_from_suffix
Oct 16, 2023
Merged

Fix Ref::new_slice_from_suffix()#506
joshlf merged 2 commits intogoogle:mainfrom
dmitryash:fix_new_slice_from_suffix

Conversation

@dmitryash
Copy link
Copy Markdown
Contributor

new_slice_from_suffix() has a bug and implemented exactly as new_slice_from_prefix(). Now part of buffer is chosen right.

Tests couldn't have caught because buffer was just zeros. Now buffer is not just zeros so that tests can prove correctness of new_slice_from_suffix().

`new_slice_from_suffix()` has a bug and implemented exactly as
`new_slice_from_prefix()`. Now part of buffer is chosen right.

Tests couldn't have caught because buffer was just zeros. Now buffer is
not just zeros so that tests can prove correctness of
`new_slice_from_suffix()`.
@dmitryash dmitryash force-pushed the fix_new_slice_from_suffix branch from 22f5e49 to 21f7974 Compare October 13, 2023 20:42
Copy link
Copy Markdown
Member

@joshlf joshlf left a comment

Choose a reason for hiding this comment

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

Awesome, thanks so much for catching this! One small change to request. I want to give some more thought to whether we should do more to beef up our tests in this PR to catch bugs like this in the future; I'll have time to do that and give more detailed feedback early this coming week.

Comment thread src/lib.rs Outdated
Co-authored-by: Joshua Liebow-Feeser <joshlf@users.noreply.github.com>
@joshlf
Copy link
Copy Markdown
Member

joshlf commented Oct 16, 2023

Not sure what's up with those failing Miri test cases. Maybe try rebasing on main? If that doesn't work, we can investigate in more depth.

joshlf added a commit that referenced this pull request Oct 16, 2023
In #506, a bug was discovered which `test_new_aligned_sized` did not
previously catch. This commit improves that test to catch that bug.
@joshlf
Copy link
Copy Markdown
Member

joshlf commented Oct 16, 2023

I've uploaded #511, which follows on this to beef up test_new_aligned_sized a bit. Once CI passes for this, I'll approve and merge and then rebase #511 on top of this.

@joshlf joshlf mentioned this pull request Oct 16, 2023
@joshlf
Copy link
Copy Markdown
Member

joshlf commented Oct 16, 2023

Note that we plan to follow up on this consistent with #512.

@joshlf joshlf added this pull request to the merge queue Oct 16, 2023
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 16, 2023
@joshlf
Copy link
Copy Markdown
Member

joshlf commented Oct 16, 2023

It appears that Miri is failing nondeterministically. I've reported the issue here: rust-lang/miri#3125. This appears to be an issue with Miri rather than with our code, so I'll try a few more times and maybe we'll get lucky with this making it through the merge queue. Obviously we'll need to fix this issue fairly soon, but there's no reason for resolving that issue to block this PR.

@joshlf joshlf added this pull request to the merge queue Oct 16, 2023
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 16, 2023
@joshlf joshlf added this pull request to the merge queue Oct 16, 2023
Merged via the queue into google:main with commit c56281b Oct 16, 2023
@joshlf
Copy link
Copy Markdown
Member

joshlf commented Oct 16, 2023

@dmitryash Out of curiosity, how did you stumble upon this issue? We're always curious to hear how zerocopy is getting used in the wild!

joshlf added a commit that referenced this pull request Oct 16, 2023
In #506, a bug was discovered which `test_new_aligned_sized` did not
previously catch. This commit improves that test to catch that bug.
joshlf added a commit that referenced this pull request Oct 18, 2023
In #506, a bug was discovered which `test_new_aligned_sized` did not
previously catch. This commit improves that test to catch that bug.
joshlf added a commit that referenced this pull request Oct 18, 2023
* Fix Ref::new_slice_from_suffix()

`new_slice_from_suffix()` has a bug and implemented exactly as
`new_slice_from_prefix()`. Now part of buffer is chosen right.

Tests couldn't have caught because buffer was just zeros. Now buffer is
not just zeros so that tests can prove correctness of
`new_slice_from_suffix()`.

* position -> split_at

Co-authored-by: Joshua Liebow-Feeser <joshlf@users.noreply.github.com>

---------

Co-authored-by: Joshua Liebow-Feeser <joshlf@users.noreply.github.com>
joshlf added a commit that referenced this pull request Oct 18, 2023
* Fix Ref::new_slice_from_suffix()

`new_slice_from_suffix()` has a bug and implemented exactly as
`new_slice_from_prefix()`. Now part of buffer is chosen right.

Tests couldn't have caught because buffer was just zeros. Now buffer is
not just zeros so that tests can prove correctness of
`new_slice_from_suffix()`.

* position -> split_at

Co-authored-by: Joshua Liebow-Feeser <joshlf@users.noreply.github.com>

---------

Co-authored-by: Joshua Liebow-Feeser <joshlf@users.noreply.github.com>
joshlf added a commit that referenced this pull request Oct 18, 2023
* Fix Ref::new_slice_from_suffix()

`new_slice_from_suffix()` has a bug and implemented exactly as
`new_slice_from_prefix()`. Now part of buffer is chosen right.

Tests couldn't have caught because buffer was just zeros. Now buffer is
not just zeros so that tests can prove correctness of
`new_slice_from_suffix()`.

* position -> split_at

Co-authored-by: Joshua Liebow-Feeser <joshlf@users.noreply.github.com>

---------

Co-authored-by: Joshua Liebow-Feeser <joshlf@users.noreply.github.com>
@dmitryash
Copy link
Copy Markdown
Contributor Author

dmitryash commented Oct 22, 2023

@joshlf I needed to decode some data that had "footer" and I tried from_suffix variant but found that it did not work correctly.

@joshlf
Copy link
Copy Markdown
Member

joshlf commented Oct 22, 2023

@joshlf I needed to decode some data that had "footer" and I tried from_suffix variant but found that it did not work correctly.

Interesting, can you say more about why it didn't work? I'd like to be able to support your use case if possible.

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