[eigen] CholmodSupport.h in Eigen 3.1 alpha returns a mapped matrix then frees the storage being mapped.

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


I mentioned this once before but did not get around to creating an
test case to show the problem.  In CholmodSupport.h the internal
_solve functions assign a mapped dense or sparse matrix to the dest
reference and then free the storage that is mapped.

For example, in the dense case the _solve function ends with


      dest = Matrix<Scalar,Dest::RowsAtCompileTime,Dest::ColsAtCompileTime>::Map(reinterpret_cast<Scalar*>(x_cd->x),b.rows(),b.cols());
      cholmod_free_dense(&x_cd, &m_cholmod);

One of the side-effects of cholmod_free_dense is to free the storage
to which x_cd->x points.

I think that the tests in eigen/unsupported/test/sparse_llt.cpp pass
because the value is tested immediately and the freed storage has not
been overwritten.

I'm not exactly sure how to create a test case to show the problem.
By default Cholmod uses malloc/free for dynamic storage and I'm not
sure how this interacts with the C++ dynamic storage allocation for
objects.  I would like to ensure that the freed chunk of storage
pointed to by x_cd->x is overwritten after the result has been
returned but that involves knowing more about malloc, etc. than I do.



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/