When Tensor::Make is called without explicit strides, ValidateTensorParameters (cpp/src/arrow/tensor.cc) only computes row-major strides and never verifies the data buffer is large enough for the shape. The buffer-overrun guard in CheckTensorStridesValidity runs only when strides are supplied. A row-major tensor whose shape exceeds its backing buffer is accepted, leading to out-of-bounds reads when the tensor is consumed.
This is reachable from IPC ReadTensor: the shape comes from the Tensor flatbuffer and the data is the message body, whose size is independent of the shape, and the flatbuffer commonly omits strides (row-major).
auto data = Buffer::Wrap(std::vector<double>{1, 2}); // 16 bytes
// shape needs 3*100*8 = 2400 bytes; currently returns OK
auto t = Tensor::Make(float64(), data, {3, 100});
When
Tensor::Makeis called without explicit strides,ValidateTensorParameters(cpp/src/arrow/tensor.cc) only computes row-major strides and never verifies the data buffer is large enough for the shape. The buffer-overrun guard inCheckTensorStridesValidityruns only when strides are supplied. A row-major tensor whose shape exceeds its backing buffer is accepted, leading to out-of-bounds reads when the tensor is consumed.This is reachable from IPC
ReadTensor: the shape comes from the Tensor flatbuffer and the data is the message body, whose size is independent of the shape, and the flatbuffer commonly omits strides (row-major).