Re: [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 ]

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] CholmodSupport.h in Eigen 3.1 alpha returns a mapped matrix then frees the storage being mapped.*From*: Douglas Bates <bates@xxxxxxxxxxxxx>*Date*: Wed, 7 Dec 2011 09:15:17 -0600*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; bh=IgEidDv/RRL55Y2eEon0YL5OtWvR2j6pqnLDpxITX+w=; b=ozo3yI0bihodWDMw71bBcK5RUR3PzNP9oGYMYhywCgof3p9+vzm+bxnL9grgBbur/l Bz7U5QE1LeUftq1A2DyiPoT8zxO/zUqFLkAZjS4eNUAWET/QjPgkcomadbFRLDb3063Q SRoq4lCtoznXdqG2V+0XSMo5brLbKT9Il5P4g=

On Tue, Dec 6, 2011 at 6:43 PM, Christoph Hertzberg <chtz@xxxxxxxxxxxxxxxxxxxxxxxx> wrote: > On 07.12.2011 00:00, Douglas Bates wrote: >> >> 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); > > > Yes, but that means the values of x_cd are copied to dest -- even if dest is > also a Map-type, operator= copies everything by value. This is not optimal, > but I don't see a critical problem with that. Though, maybe I'm missing > something? Thank you, Christoph. I should have realized that. >> 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. > > > The easiest way to test is to run the test with valgrind (assuming you run > linux), which would give you (at least) a warning as soon as freed memory is > accessed. Yes. Again, I should have realized that. Sorry for the noise. > You could also modify the _solve-function and overwrite the values in > x_cd->x immediately before cholmod_free_dense is called.

**References**:

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] 3.1.0-alpha1 released!** - Next by Date:
**Re: [eigen] Status of AVX support** - Previous by thread:
**Re: [eigen] CholmodSupport.h in Eigen 3.1 alpha returns a mapped matrix then frees the storage being mapped.** - Next by thread:
**[eigen] Ambiguous call**

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