Repository navigation
Conversation
|
I encountered a silent data corruption in my own code: when reusing a pre-allocated Vec buffer, wrong values were silently accepted without any error, making the bug extremely hard to detect. |
|
hey, author of #3589 here (just closed it in favor of this one). your fix in one thing worth checking before merge though. also theres no test here yet. i already have two ready from #3589, they fail before the fix and pass after, covering the constructor entry points: maintainers usually like the coverage landing with the fix rather than as a separate PR later, so happy to just add them onto this one. if you add me as a collaborator on your fork i can push the tests straight to your branch, or i can open a small PR against your branch and you merge it in, whatever is easier for you. nice catch on the root cause btw. |
|
@pjdurden, |
|
Pushed the two regression tests to the branch (constructor entry points, red-before/green-after): I left the reshape dead-code cleanup out of this PR. |
Add element count validation in into_shape method.
Add regression tests for from_slice/from_vec/from_raw_buffer rejecting a declared shape whose element count does not match the data length, plus the matching-shape and one-hole inference cases that must still pass (huggingface#3534). Co-authored-by: oyoyo4556 <[email protected]>
28176f6 to
dcabee8
Compare
Closes #3534
This PR adds the missing shape element count validation in the
ShapeWithOneHoleblanket implementation forS: Into<Shape>.Previously, the
_el_countparameter was ignored, allowing the creation of tensors with invalid shapes, which led to out-of-bounds reads and panics (especially via the ONNX loader as reported in #3534).Please feel free to modify or add regression tests if needed!