-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
Revert PR #197 and re-implement to fix incorrect buffer writes #219
Conversation
This reverts commit 1a23b74.
…reventing the wrong times to be submitted. The previous (reverted) Fix for this allowed for AsRef<Vec> types to be passed in, causing incorrect buffer sizes and writes.
Codecov Report
@@ Coverage Diff @@
## master #219 +/- ##
=======================================
Coverage 87.57% 87.57%
=======================================
Files 6 6
Lines 169 169
=======================================
Hits 148 148
Misses 21 21
Continue to review full report at Codecov.
|
The odd arrays problem is not big in practice as any array size can be converted to slice, and slice of arrays can be converted into a flat slice as well. The only case where this could be a problem is custom structs with oddly sized slices inside, but even that can be worked around by converting into |
Passing |
About slices:
|
I think having Having |
That's why I suggest asserting that type is |
From
|
This doesn't really seem like something to reliably static assert on. It seems the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Good points.
bors r=frizi,omni-viral |
219: Revert PR #197 and re-implement to fix incorrect buffer writes r=frizi,omni-viral a=jaynus #197 unintentionally allowed for incorrectly writing `Vec` types when collected and submitted. This was discussed in the PR and actually seen, where a crash was mentioned, but it was *incorrectly* assumed to be an upstream problem. The change in #197 caused `upload_*` functions to accept a plain `Vec` as `&T` can AsRef a `Vec`, which was then cast incorrectly to a u8 and submitted. This was only evident in the `quads` example because it is the only example which actually provides a `Vec` type (from a `Vec::collect` call) for a buffer upload. This PR reverts #197 and changes the fix for #58 to the original concept of just bounding T: 'static + Copy, instead of changing from `&[T]` to `&T`. As discussed in #197, this will have problems with large arrays being submitted - but we can just ignore that, as its unrealistic; it is better to *correctly* accept `Vec` types for large arrays, instead of compensating for large static slices which will almost never exist. Co-authored-by: jaynus <jaynus@gmail.com>
Build succeeded |
#197 unintentionally allowed for incorrectly writing
Vec
types when collected and submitted. This was discussed in the PR and actually seen, where a crash was mentioned, but it was incorrectly assumed to be an upstream problem. The change in #197 causedupload_*
functions to accept a plainVec
as&T
can AsRef aVec
, which was then cast incorrectly to a u8 and submitted.This was only evident in the
quads
example because it is the only example which actually provides aVec
type (from aVec::collect
call) for a buffer upload.This PR reverts #197 and changes the fix for #58 to the original concept of just bounding T: 'static + Copy, instead of changing from
&[T]
to&T
. As discussed in #197, this will have problems with large arrays being submitted - but we can just ignore that, as its unrealistic; it is better to correctly acceptVec
types for large arrays, instead of compensating for large static slices which will almost never exist.