Adding TMatrixD in for loop (4.00-08)

Hi,

I am using root version 4.00-08 ( I tried Linux 2.4.28 on opteron and
2.4.20-30HEP2.7smp Pentium3) and I see some funny behavior
when trying to add TMatrixDs within a for loop.

Here is a small example:
root [0] TMatrixD mat1(5,5)
root [1] TMatrixD mat2(5,5)
root [2] TMatrixD mat3(5,5)

I can add them by hand as often as I wish:
root [3] mat1 = mat2 + mat3
(class TMatrixD)147167584
root [4] mat1 = mat2 + mat3
(class TMatrixD)147167584

Putting this in a loop which is run once, things are fine, too:
root [5] for(int i=1; i<2; i++){mat1 = mat2 + mat3;}

But trying to go through the loop twice:
root [6] for(int i=1; i<3; i++){mat1 = mat2 + mat3;}

*** Break *** segmentation violation
Generating stack trace…
0x412ce678 in from /lib/libc.so.6
0x4106201e in TMatrixD::TMatrixD(TMatrixD const &) + 0xb6 from /groups/babar/package/root/4.00-08/Linux24RH72_i386_gcc2953/lib/libMatrix.so
0x410678e5 in operator+(TMatrixD const &, TMatrixD const &) + 0x2d from /groups/babar/package/root/4.00-08/Linux24RH72_i386_gcc2953/lib/libMatrix.so

Am I missing something obvious here?
I tried root version 3.02-07 on the Pentium3 and did not see this problem.

Kerstin

Hi Kerstin,

This seems to be a CINT short-coming . Having a file doit.C
with the following contents :

#include “TMatrixD.h”

void doit()
{
TMatrixD *mat1 = new TMatrixD(5,5);
TMatrixD *mat2 = new TMatrixD(5,5);
TMatrixD *mat3 = new TMatrixD(5,5);
for (Int_t i=0; i<2; i++)
*mat1 = *mat2 + *mat3;
}

you can convince yourself that

  1. ACLiC is fine:

root [0] .L doit.C++
Info in TUnixSystem::ACLiC: creating shared library /Users/eddyo/src/ROOT/root-4.03.01/test/./doit_C.so
ld: warning -prebind has no effect with -bundle
root [1] doit()

  1. .L doit.C fails:

root [0] .L doit.C
root [1] doit()
Fatal in TMatrixD::: another.IsValid() violated at line 69 of `matrix/src/TMatrixD.cxx’
aborting

  1. .x doit.C fails:

root [0] .x doit.C

*** Break *** bus error
Root > Function doit() busy flag cleared

Eddy