Weird behavior where kernel crashes when substituting expression, depending on how the expression is written

+1 vote

As the title says, kernel crashes when running the code below as a cadabra notebook (.cnb) (specifically, when running the substitute algorithm)

{t}::Coordinate;

viel := {
ei^{t}_{t} = Q / (f**2 - Q**2)
};

substitute(viel, $f = (Q**2 - \alpha / r**4 )**(1/2)$);

Running it as a .cdb file in a terminal, the error given is "realloc(): Invalid old size".

Here is a variation of the code where it still crashes:

{t}::Coordinate;

viel := {
ei^{t}_{t} = Q / (f - Q**2)
};

substitute(viel, $f = (Q**2 - \alpha / r**4 )$);

The code doesn't crash, however, if I factorize a minus sign in the denominator, as in

{t}::Coordinate;

viel := {
ei^{t}_{t} = - Q / (Q**2 - f**2)
};

substitute(viel, $f = (Q**2 - \alpha / r**4 )**(1/2)$);

or if I pass the numerator to the denominator

{t}::Coordinate;

viel := {
ei^{t}_{t} = 1 / ( (f**2 - Q**2) / Q )
};

substitute(viel, $f = (Q**2 - \alpha / r**4 )**(1/2)$);

This was due to an issue when simplifying powers of rationals, in particular things of the form $(-a)^{-1}$, which left unsimplified rationals in the expression tree.