Skip to content

out-of-bounds access in rankUpdate(<0-by-n>)

Summary

Environment

  • Operating System : macOS 13
  • Architecture : AArch64
  • Eigen Version : 3.4.0
  • Compiler Version : Apple clang 14.0.3
  • Compile Flags : -g -O0 -fsanitize=undefined
  • Vector Extension :

Minimal Example

/* test.cpp */
#include <Eigen/Dense>
int main()
{
	Eigen::Map<Eigen::MatrixXd> A  ((double *) NULL, 0, 1);
	Eigen::Map<Eigen::MatrixXd> AAt((double *) NULL, 0, 0);
	AAt.selfadjointView<Eigen::Upper>().rankUpdate(A);
	return 0;
}

Steps to reproduce

$ ${CXX} -g -O0 -fsanitize=undefined -I"${EIGEN_PREFIX}" test.cpp -o test.o && ./test.o

What is the current bug behavior?

Method dereferences null pointer or pointer to 0-length array.

What is the expected correct behavior?

A no-op in the 0-row case.

Relevant logs

Eigen/src/Core/util/BlasUtil.h:193:12: runtime error: reference binding to null pointer of type 'const double'
    #0 0x104cb53fc in Eigen::internal::general_matrix_matrix_triangular_product<long, double, 0, false, double, 1, false, 0, 1, 2, 0>::run(long, long, double const*, long, double const*, long, double*, long, long, double const&, Eigen::internal::level3_blocking<double, double>&) GeneralMatrixMatrixTriangular.h:100
    #1 0x104cb4028 in Eigen::selfadjoint_product_selector<Eigen::Map<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 0, Eigen::Stride<0, 0>>, Eigen::Map<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 0, Eigen::Stride<0, 0>>, 2, false>::run(Eigen::Map<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 0, Eigen::Stride<0, 0>>&, Eigen::Map<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 0, Eigen::Stride<0, 0>> const&, double const&) SelfadjointProduct.h:109
    #2 0x104cb28a0 in Eigen::SelfAdjointView<Eigen::Map<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 0, Eigen::Stride<0, 0>>, 2u>& Eigen::SelfAdjointView<Eigen::Map<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 0, Eigen::Stride<0, 0>>, 2u>::rankUpdate<Eigen::Map<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 0, Eigen::Stride<0, 0>>>(Eigen::MatrixBase<Eigen::Map<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 0, Eigen::Stride<0, 0>>> const&, double const&) SelfadjointProduct.h:126
    #3 0x104cb24bc in main test.cpp:5
    #4 0x194ecbf24  (<unknown module>)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Eigen/src/Core/util/BlasUtil.h:193:12 in 

Anything else that might help

  • Have a plan to fix this issue.