Re: [eigen] Possible undefined behavior in insert() in SparseMatrix |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Possible undefined behavior in insert() in SparseMatrix
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Thu, 7 May 2009 15:19:06 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=G9ST+VmReihSkE/74Zayq9g23Ekd3phDwnlMnkTAYgU=; b=ZxNXIK3pbq+Jka6oPzi38qjAm8ZiES/gC22QjhKtGJ2/bwadEr1WBJTCNWaLQAhNpB uv2Jooc7IgoU/GUaScbkKBaG9ClosNfkQtK+jEXQhD/TfVTA5ihIKfBKiqcTWh5JOsJr 5f0KnqZ7Ch/lrVT0ZEu6OcDY/eBAannN3qtEU=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=t8wgXhdZAVs8rK5e52A6od/VqFY0yfdeqeDwvkIh0dc5k5pSU7kXsZ2An0ZcO5wXCZ kFJ+/Jaql0XmSOIeP28oI9xS7KNNYzVZ8hO5CKaA21bD6c32hLsQtDlGswzAr8jxdL7L qg0tZk6Zm9np3nnKZiCUvkHb6eFRubHnxAaWk=
Thanks, bug fixed.
On Thu, May 7, 2009 at 2:47 PM, Jens Mueller <jens.k.mueller@xxxxxx> wrote:
> Hi,
>
> I justed checked the new insert() method for the SparseMatrix. There
> seems to be a problem, if the actual size is 0. So assuming you created
> a new sparse matrix and ran setZero() but no reserve(). And then you
> start inserting. In that case line 251 in SparseMatrix results in a nan
> (due to division by zero). And the following std::max and std::min
> operations have undefined behavior when passing a nan. In my case I get
> a nan as value for reallocRatio. And this may result in
> CompressedStorage's resize to allocate really much memory.
> For me I even get a std::bad_alloc, if my Scalar type is an unsigned
> char (checked attached code). For some reason I don't get it for int.
> This is strange to me. But another issue I don not understand yet.
>
> Regards,
> Jens
>