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

Debug assert to verify the correctness at DeframerVecBuffer #1929

Closed
wants to merge 2 commits into from

Conversation

MOZGIII
Copy link
Contributor

@MOZGIII MOZGIII commented Apr 29, 2024

Follow up after #1798 (comment)

@MOZGIII MOZGIII marked this pull request as draft April 29, 2024 17:46
@MOZGIII MOZGIII marked this pull request as ready for review April 29, 2024 17:49
@@ -504,7 +504,8 @@ impl DeframerBuffer<'_, InternalPayload> for DeframerVecBuffer {

#[cfg(feature = "std")]
impl<'a> DeframerBuffer<'a, ExternalPayload<'a>> for DeframerVecBuffer {
fn copy(&mut self, payload: &ExternalPayload<'a>, _at: usize) {
fn copy(&mut self, payload: &ExternalPayload<'a>, at: usize) {
debug_assert_eq!(at, self.used);
Copy link
Member

Choose a reason for hiding this comment

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

You also indicated you thought some of the context from the fix commit message deserved to be a comment. That sounds reasonable to me, could you roll that into this diff?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I was thinking about that too. However it is not trivial how to formulate this context from a commit message explaining why this was changes into a more permanent why is it "ok to be like this" comment for the code.
While thinking about it - I figures that maybe this is actually not an ok thing to have - and a broader remodelling of how this trait and in general part of logic is in order.

If you can agree this is the case - that is what I'll capture and add as a comment.

Copy link

codecov bot commented Apr 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.49%. Comparing base (59c33df) to head (c419aaa).

❗ Current head c419aaa differs from pull request most recent head c481f8c. Consider uploading reports for the commit c481f8c to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1929   +/-   ##
=======================================
  Coverage   95.49%   95.49%           
=======================================
  Files          86       86           
  Lines       18650    18651    +1     
=======================================
+ Hits        17810    17811    +1     
  Misses        840      840           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MOZGIII
Copy link
Contributor Author

MOZGIII commented Apr 29, 2024

Actually, is this even correct? it seems like the at position should just be computed relative to the current level of filling in the buffer - but that adjustment has to be done prior to calling of the copy fn...

@cpu
Copy link
Member

cpu commented May 16, 2024

Thanks for the contribution. I chatted about this branch with the other maintainers and we've reached the conclusion we'd like to close this for now. As mentioned in the other thread we would be supportive of a broader refactor to address some of the awkward workarounds that remain in this area. Outside of that, if you have other concerns about the fix we landed it would be beneficial to have them articulated in a separate issue, ideally with a concrete case in which the existing fix can be demonstrated as insufficient.

@cpu cpu closed this May 16, 2024
@MOZGIII
Copy link
Contributor Author

MOZGIII commented May 16, 2024

A quick question here though: in your discussion, did you conclude this invariant check that I have added wouldn't hold? Cause if that's the case then there is likely a corruption possible here that might be exploited as a vulnerability.

@cpu
Copy link
Member

cpu commented May 16, 2024

We believe the invariant holds.

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.

None yet

2 participants