Re: [eigen] Segfault in test matrixExponential_2 |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Segfault in test matrixExponential_2
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Sat, 14 Nov 2009 21:41:02 -0500
- 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=7vqms53K4WvsOJI9XfZjEsIq9twGTdKp5BOWyb9PAzM=; b=WDl/sZVa/DSzK1HSEVG0pdzP52GzNPjOn9CDp6W+seJhVbhrJqRBmikuDe0UUy0Fc+ +r7EV2y3jEtGAjJR66EyaoN77b/mChuOZbSVvqgz5seOftNaAIIjUFSuQCT9GoVzfzca rgWeM8fW6JhSIJGfeW00/ZlEUzlV3hMUTy9dI=
- 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=Eyn1SVjauTvVsZiTHYw4irnkSflcoCVe8VjI1fyhoyvFaS2F6Yv7W82h8ct9zTplAc B2oHC1zEYUsYesYykywwHxrGHFnuEnRrICJDT1PHUFxRTRGsdqQltl8jkvqbKjP75VLU 5aCvftrAijHl27vQ6rUBy+Whx85l3Jzwv7SyE=
2009/11/14 Jitse Niesen <jitse@xxxxxxxxxxxxxxxxx>:
> Hello,
>
> I'm trying to understand a segmentation fault in the matrixExponential_2
> test in unsupported/test. Unfortunately, it's rather sensitive: when I start
> removing code in an attempt to get a minimal test example, the segmentation
> fault disappears, even though the code has nothing to do with it. The
> segfault only happens when compiling with g++ 4.3 with the flags -O2 and
> -msse2; it disappears when using g++ 4.4 (so perhaps I should not bother
> ...).
Argh. Here on x86_64 / g++-4.3, I can't reproduce. -O2 is the default
now, and -msse2 is implicit on x86_64.
>
> I did manage to get a backtrace (compiled with -g2 -fno-inline); see below.
> The arguments in frame #1 are wrong (this = 0x0), but 'this' in frame #1
> should be the same as dst in frame #2. I guess that means that the stack
> frame is corrupted by a dangling pointer?
hm, that would be very bad luck! The common cause for stack corruption
would be a stack overflow, but here that doesn't seem to be the case
as the call stack depth is only 18.
Isn't it more natural to infer that some object is being used
uninitialized? That's where I would start looking. Then, the most
likely cause would be a temporary that dies too early.
>
> I'm not sure of the best way to proceed. One problem is that it's deep in
> Eigen's internal code which I don't understand. Any suggestions?
So the crash is in ei_pload. There are 2 ways that ei_pload may crash:
- if the 'from' pointer is dangling
- if the 'from' pointer is not 16-byte aligned and this is an aligned load..
Here, the pointer 0xbffb7720 is aligned, so it has to be dangling,
which goes well with the assumption that the object is frame #1 is
uninitialized.
So now, to fix this bug, it happens at line 264 in PartialPivLU.h, which is:
lu.corner(BottomRight,rrows,rsize).noalias()
-= lu.col(k).end(rrows) * lu.row(k).end(rsize);
Just a wild question: what happens if you remove the noalias() there?
Benoit
>
> Thanks,
> Jitse
>
>
>
> Backtrace from gdb:
>
> #0 0x08049957 in Eigen::ei_pload<double> (from=0xbffb7720)
> at ../Eigen/src/Core/arch/SSE/PacketMath.h:176
> #1 0x0807844e in
> Eigen::MatrixBase<Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double,
> 33331, 33331, 1, 33331, 33331>, 0>, 33331, 33331, 0, 32>, 33331, 33331, 0,
> 32>, 1, 33331, 0, 32>
>>::copyPacket<Eigen::CwiseBinaryOp<Eigen::ei_scalar_sum_op<double>,
> Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double,
> 33331, 33331, 1, 33331, 33331>, 0>, 33331, 33331, 0, 32>, 33331, 33331, 0,
> 32>, 1, 33331, 2, 32>,
> Eigen::CwiseUnaryOp<Eigen::ei_scalar_multiple_op<double>,
> Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double,
> 33331, 33331, 1, 33331, 33331>, 0>, 33331, 33331, 0, 32>, 1, 33331, 0, 32>,
> 1, 33331, 0, 32> > >, 1, 0> (this=0x0, index=-1074039000,
> other=@0xbffb7720) at ../Eigen/src/Core/Coeffs.h:378
> #2 0x08078541 in
> Eigen::ei_assign_impl<Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double,
> 33331, 33331, 1, 33331, 33331>, 0>, 33331, 33331, 0, 32>, 33331, 33331, 0,
> 32>, 1, 33331, 0, 32>, Eigen::CwiseBinaryOp<Eigen::ei_scalar_sum_op<double>,
> Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double,
> 33331, 33331, 1, 33331, 33331>, 0>, 33331, 33331, 0, 32>, 33331, 33331, 0,
> 32>, 1, 33331, 2, 32>,
> Eigen::CwiseUnaryOp<Eigen::ei_scalar_multiple_op<double>,
> Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double,
> 33331, 33331, 1, 33331, 33331>, 0>, 33331, 33331, 0, 32>, 1, 33331, 0, 32>,
> 1, 33331, 0, 32> > >, 1, 0>::run (dst=@0xbffb7774, src=@0xbffb7720)
> at ../Eigen/src/Core/Assign.h:341
> #3 0x080785d2 in
> Eigen::MatrixBase<Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double,
> 33331, 33331, 1, 33331, 33331>, 0>, 33331, 33331, 0, 32>, 33331, 33331, 0,
> 32>, 1, 33331, 0, 32>
>>::lazyAssign<Eigen::CwiseBinaryOp<Eigen::ei_scalar_sum_op<double>,
> Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double,
> 33331, 33331, 1, 33331, 33331>, 0>, 33331, 33331, 0, 32>, 33331, 33331, 0,
> 32>, 1, 33331, 2, 32>,
> Eigen::CwiseUnaryOp<Eigen::ei_scalar_multiple_op<double>,
> Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double,
> 33331, 33331, 1, 33331, 33331>, 0>, 33331, 33331, 0, 32>, 1, 33331, 0, 32>,
> 1, 33331, 0, 32> > > > (this=0xbffb7774, other=@0xbffb7720)
> at ../Eigen/src/Core/Assign.h:429
> #4 0x08078711 in
> Eigen::MapBase<Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double,
> 33331, 33331, 1, 33331, 33331>, 0>, 33331, 33331, 0, 32>, 33331, 33331, 0,
> 32>, 1, 33331, 0, 32>
>>::operator+=<Eigen::CwiseUnaryOp<Eigen::ei_scalar_multiple_op<double>,
> Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double,
> 33331, 33331, 1, 33331, 33331>, 0>, 33331, 33331, 0, 32>, 1, 33331, 0, 32>,
> 1, 33331, 0, 32> > > (this=0xbffb7774,
> other=@0xbffb7784) at ../Eigen/src/Core/MapBase.h:214
> #5 0x080787b5 in
> Eigen::ei_outer_product_selector<1>::run<Eigen::GeneralProduct<Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double,
> 33331, 33331, 1, 33331, 33331>, 0>, 33331, 33331, 0, 32>, 33331, 1, 0, 32>,
> 33331, 1, 0, 32>,
> Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double,
> 33331, 33331, 1, 33331, 33331>, 0>, 33331, 33331, 0, 32>, 1, 33331, 0, 32>,
> 1, 33331, 0, 32>, 0>,
> Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double, 33331, 33331, 1,
> 33331, 33331>, 0>, 33331, 33331, 0, 32>, 33331, 33331, 0, 32> >
> (prod=@0xbffb78d8, dest=@0xbffb7828, alpha=-1)
> at ../Eigen/src/Core/Product.h:237
> #6 0x08078840 in
> Eigen::ProductBase<Eigen::GeneralProduct<Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double,
> 33331, 33331, 1, 33331, 33331>, 0>, 33331, 33331, 0, 32>, 33331, 1, 0, 32>,
> 33331, 1, 0, 32>,
> Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double,
> 33331, 33331, 1, 33331, 33331>, 0>, 33331, 33331, 0, 32>, 1, 33331, 0, 32>,
> 1, 33331, 0, 32>, 0>,
> Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double,
> 33331, 33331, 1, 33331, 33331>, 0>, 33331, 33331, 0, 32>, 33331, 1, 0, 32>,
> 33331, 1, 0, 32>,
> Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double,
> 33331, 33331, 1, 33331, 33331>, 0>, 33331, 33331, 0, 32>, 1, 33331, 0, 32>,
> 1, 33331, 0, 32>
>>::subTo<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double, 33331,
> 33331, 1, 33331, 33331>, 0>, 33331, 33331, 0, 32>, 33331, 33331, 0, 32> >
> (this=0xbffb78d8, dst=@0xbffb7828)
> at ../Eigen/src/Core/ProductBase.h:109
> #7 0x08078878 in
> Eigen::NoAlias<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double,
> 33331, 33331, 1, 33331, 33331>, 0>, 33331, 33331, 0, 32>, 33331, 33331, 0,
> 32>
>>::operator-=<Eigen::GeneralProduct<Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double,
> 33331, 33331, 1, 33331, 33331>, 0>, 33331, 33331, 0, 32>, 33331, 1, 0, 32>,
> 33331, 1, 0, 32>,
> Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double,
> 33331, 33331, 1, 33331, 33331>, 0>, 33331, 33331, 0, 32>, 1, 33331, 0, 32>,
> 1, 33331, 0, 32>, 0>,
> Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double,
> 33331, 33331, 1, 33331, 33331>, 0>, 33331, 33331, 0, 32>, 33331, 1, 0, 32>,
> 33331, 1, 0, 32>,
> Eigen::Block<Eigen::Block<Eigen::Block<Eigen::Map<Eigen::Matrix<double,
> 33331, 33331, 1, 33331, 33331>, 0>, 33331, 33331, 0, 32>, 1, 33331, 0, 32>,
> 1, 33331, 0, 32> > (this=0xbffb78e8, other=@0xbffb78d8) at
> ../Eigen/src/Core/NoAlias.h:71
> #8 0x08078b5e in Eigen::ei_partial_lu_impl<double, 1>::unblocked_lu (
> lu=@0xbffb79e4, row_transpositions=0xbffb7a8c,
> nb_transpositions=@0xbffb7a98) at ../Eigen/src/LU/PartialPivLU.h:264
> #9 0x08084e38 in Eigen::ei_partial_lu_impl<double, 1>::blocked_lu (rows=3,
> cols=3, lu_data=0xbffb7b2c, luStride=3, row_transpositions=0xbffb7a8c,
> nb_transpositions=@0xbffb7a98, maxBlockSize=256)
> at ../Eigen/src/LU/PartialPivLU.h:297
> #10 0x08084f49 in Eigen::ei_partial_lu_inplace<Eigen::Matrix<double, 3, 3,
> 1, 3, 3>, Eigen::Matrix<int, 3, 1, 0, 3, 1> > (lu=@0xbffb7b2c,
> row_transpositions=@0xbffb7a8c, nb_transpositions=@0xbffb7a98)
> at ../Eigen/src/LU/PartialPivLU.h:373
> #11 0x0808502a in Eigen::PartialPivLU<Eigen::Matrix<double, 3, 3, 1, 3, 3>
>>::compute (this=0xbffb7b2c, matrix=@0xbffb7cf0)
> at ../Eigen/src/LU/PartialPivLU.h:390
> #12 0x0808514f in PartialPivLU (this=0xbffb7b2c, matrix=@0xbffb7cf0)
> at ../Eigen/src/LU/PartialPivLU.h:198
> #13 0x080851a1 in Eigen::MatrixBase<Eigen::Matrix<double, 3, 3, 1, 3, 3>
>>::partialPivLu (this=0xbffb7cf0) at ../Eigen/src/LU/PartialPivLU.h:453
> #14 0x08085ef2 in MatrixExponential (this=0xbffb7c14, M=@0xbffb7d88,
> result=0xbffb7e88)
> at ../unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h:195
> #15 0x08086035 in Eigen::ei_matrix_exponential<Eigen::Matrix<double, 3, 3,
> 1, 3, 3> > (M=@0xbffb7ed0, result=0xbffb7e88)
> at ../unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h:304
> #16 0x0808b32a in randomTest<Eigen::Matrix<double, 3, 3, 1, 3, 3> > (
> m=@0xbffb7f68, tol=1e-13) at
> ../unsupported/test/matrixExponential.cpp:105
> #17 0x08049425 in test_matrixExponential ()
> at ../unsupported/test/matrixExponential.cpp:120
> #18 0x0804965b in main (argc=1, argv=Cannot access memory at address 0x6
> ) at ../test/main.h:445
>
>
>