Opened 13 years ago

Closed 12 years ago

# Nasty bug in noncomm multiplication

Reported by: Owned by: levandov Oleksandr major 3-1-2 and higher singular-kernel 3-1-1 noncommutative; multiplication

### Description

Dear colleagues,

Daniel Andres (my student at RWTH Aachen) has detected a nasty bug in the non-commutative multiplication.

The code is simple as follows:

```ring r = 0,(x,y),dp; matrix D[2][2]; D[1,2] = y^2;
def R = nc_algebra(1,D); setring R; R;
y^5*x^5;
```

one gets

SIGSEGV, Segmentation fault.

0x0050e004 in gnc_uu_Mult_ww_vert (i=2, a=5, j=1, b=5, r=0x7fec1784)

at gring.cc:1029

1029 MATELEM(cMT,a,m) = nc_p_CopyPut(t,r);

I traced the problem back to the following:
after the execution of the line ( in gring.cc)

```1028          t = gnc_p_Mult_mm(t,x,r);
```

the matrix cMT, which [i,j]-th entry carries the product yi*xj, will be corrupted. This happens for i=5 and j=4 and, funny enough, not before[[BR]]

gnc_p_Mult_mm invokes the new code by Alex Motsak, so I invite Alex to analyze what is going wrong there and why at some place the matrix cMT gets deleted...

I've tried this example with Singular versions back to 3-0-3, it is always there :-(((

With best regards, Viktor

### comment:1 Changed 12 years ago by Oleksandr

Resolution: → fixed new → closed

Bug was ALWAYS present due to the following (premature optimization) in nc_uu_Mult_ww_vert from gring.cc:

```  matrix cMT=r->nc->MT[UPMATELEM(j,i,rN)];         /* cMT=current MT */
```

since nc_mm_Mult_p/nc_p_Mult_mm can change the non-commutative-ring-wide cache MT.

Version 0, edited 12 years ago by Oleksandr (next)