Re: [eigen] cwiseop_1 test failure |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] cwiseop_1 test failure
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Fri, 11 Jun 2010 14:57:55 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=i533b2hLyKkCISB5a8RkOFNsGi+WleIblfZbY+qdQGQ=; b=itU0ufuov9eBfjJrK2c9k6Y9utR3afkyGBsLQZLkAvMYOXyU6ivxn4Dqc6wyN94p2j HPp1LDzD+B+MDrYhwu3zI3YK/O0s+aMh+cNTFhmpPnpi6CEpL/EbSKwAmGrtqwgKQg7h wLa6+5b4hoIMlZUEhz44Za9RWL114exmVIbxE=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=VOCe5oHsuuzo9YKh5NjMF7uzZYsbvlyJyNvS5Fq6SuHVg31eRuxsfiuZc/BWq/KSfG aFlytTM4PZCntiKQXCcTiSHM3grd/uAOrI5hq8TnBwOY7WZ4rvrqo2MMgGnGVKRhii2z Njs9YSHwAqC8FmcMKn7CTDMEp+mmu4Z+/+6N0=
to be honest I really think this is a GCC issue like the one I
reported here a couple of months ago:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42255
At that time this bug only showed up with when coverage testing was
enabled, but it seems to me we are now hitting the same bug with -O2
only.
Indeed, I rewrote the test_ei_isApprox function like this:
EIGEN_DONT_INLINE void foo(bool& x) {x=x;}
template<typename Type1, typename Type2>
EIGEN_DONT_INLINE bool test_ei_isApprox(const Type1& a, const Type2& b)
{
bool ret = a.isApprox(b, test_precision<typename Type1::Scalar>());
foo(ret);
return ret;
}
and that fixed the issue (both the failure and valgrind's issue).
However, if I comment the line foo(ret);, then the issue shows up.
Note that here Type1 == Type1 == Matrix<float, 1, 1>. It cannot be
more trivial.
I even get a segfault at the line return a.isApprox(b); when doing:
template<typename Type1, typename Type2>
inline bool test_ei_isApprox(const Type1& a, const Type2& b)
{
bool ret;
std::cerr << a << " == " << b << " " << (a-b) << " " << (ret =
a.isApprox(b)) << "\n";
return a.isApprox(b);
}
Really strange.
gael
On Fri, Jun 11, 2010 at 12:41 PM, Jitse Niesen <jitse@xxxxxxxxxxxxxxxxx> wrote:
> Hello,
>
> I had a quick look at the cwiseop_1 test, which according to the dash board
> fails on both Gael's and my computer but only with GCC 4.3.
>
> I did not get very far and I have other commitments at the moment (and I've
> also run out of ideas), but perhaps somebody can continue from here.
>
> The offending line is
>
> VERIFY_IS_APPROX(m4.setConstant(s1), m3);
>
> Here, m3 and m4 are of type MatrixType = Matrix<1,1,float>, s1 is a random
> float, and m3 is set to MatrixType::Constant(1,1,s1).
>
> I did not manage to get an self-contained test case, though given more time
> this should be possible.
>
> valgrind reports:
> Use of uninitialised value of size 4
> at 0x804A35F: bool Eigen::test_ei_isApprox<Eigen::Matrix<float, 1, 1, 0,
> 1, 1>, Eigen::Matrix<float, 1, 1, 0, 1, 1> >(Eigen::Matrix<float, 1, 1, 0,
> 1, 1> const&, Eigen::Matrix<float, 1, 1, 0, 1, 1> const&) (in .../cwiseop_1)
> by 0x804AE1E: void cwiseops<Eigen::Matrix<float, 1, 1, 0, 1, 1>
>>(Eigen::Matrix<float, 1, 1, 0, 1, 1> const&) (in .../cwiseop_1)
> by 0x8049DB9: test_cwiseop() (in .../cwiseop_1)
> by 0x804A0EA: main (in .../cwiseop_1)
>
> The error persists if I replace
>
> VERIFY_IS_APPROX(m4.setConstant(s1), m3);
>
> by
>
> VERIFY(test_ei_isApprox(m4.setConstant(s1), m3));
>
> However, the error goes away if I replace it by
>
> VERIFY(m4.setConstant(s1).isApprox(m3, test_precision<typename
> MatrixType::Scalar>()));
>
> As far as I see, this is just inlining the definition of test_ei_isApprox,
> so I don't see why this makes a difference.
>
>
> Jitse
>
>
>
>