|Re: [eigen] CholmodSupport.h in Eigen 3.1 alpha returns a mapped matrix then frees the storage being mapped.|
[ Thread 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: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Wed, 7 Dec 2011 09:57:17 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=5Q+5Pm+80sbPblXU6ik5fs3KRgY0kqjayYfwaNVvybc=; b=Z6lWGwA217l0RwsXwDNBTgtFU1duSup1rI1QECBrE3Cz0u7+ixtx9xFZ6OTLN4mU6H 2UwtGsvBNWkhxlsZw62Tg/4UAFf6//yg+LTndzQ1EXJJ9Hjs3Hgj9j2LgBwqLWlhecNi lu9AqkiP9D42gke3qd+hMnUXjWAJN7Cii8pcA=
Same here, I don't see anything wrong here.
On Wed, Dec 7, 2011 at 1:43 AM, Christoph Hertzberg
> 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 =
> 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
>> 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
> You could also modify the _solve-function and overwrite the values in
> x_cd->x immediately before cholmod_free_dense is called.
> Dipl.-Inf. Christoph Hertzberg
> Cartesium 0.051
> Universität Bremen
> Enrique-Schmidt-Straße 5
> 28359 Bremen
> Tel: (+49) 421-218-64252