fix(core): validate shape element count in ShapeWithOneHole blanket impl (#3534)#3572
fix(core): validate shape element count in ShapeWithOneHole blanket impl (#3534)#3572oyoyo4556 wants to merge 1 commit into
Conversation
Add element count validation in into_shape method.
|
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. |
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!