segmentation fault in simplify_indexed --> solved?

Chris Dams chrisd at sci.kun.nl
Tue Jun 25 15:30:37 CEST 2002


Hello everybody,

I think I have solved an error in GiNaC that sometimes (only in special
circumstances) causes a segmentation fault when *simplify_indexed* is
called. The problem occurs when the function *diracgamma::contract_with*
is sometimes called with the arguments *self* and *other* pointing to two
gamma matrices of different representation label. In that case it can
happen that there is a gamma5 in between and that the function
*base_and_index* is called with the gamma5 in its first argument.  This is
wrong because base_and_index tries to look at operand number 1, which does
not exist for a gamma5. This then may cause a segmentation fault. It never
happens for gamma matrices of the same rep. label because the gamma5 has
been permuted out of the way then.

I found that the segmentation fault dissapears when inside the first
*if* in *diracgamma::contract_with* I add a test that checks if rep.
labels are equal (the contract-gamma-matrices algorithms there, do not
seem to make much sense if rep. lables are different anyway). After my
addition the code looks like

if (is_a<clifford>(*other)) {
   unsigned char rl2 =ex_to<clifford>(*other).get_representation_label();
   if(rl!=rl2)
      return false;
   ex dim = ex_to<idx>(self->op(1)).get_dim();

where the first and last line are yours and the three in the middle are
mine. (BTW this is GiNaC-1.0.8).

Greetings,
Chris




More information about the GiNaC-list mailing list