Opened 6 years ago

Closed 5 years ago

# crash in multipolynomial substitutions

Reported by: Owned by: cnassau critical sage-6.10 algebra crash, SIGSEGV, substitution Vincent Delecroix Volker Braun N/A f1d8e84 f1d8e8486b815f134eda82bc726bd97964d5c0df

The substitution code for multipolynomial (using Singular) results in a SIGSEV. For example, with `R.<x,y,z> = QQ[]` and any of

```x.subs(None,y=x,x=0,z=y)
x.subs(None,x=0,y=x,z=x)
x.subs(None,x=0,y=0,z=x)
x.subs(None,x=0,y=0,z=z)
```

Though, if we do not mix integer and variable in the substitutions it seems to work fine

```sage: x.subs(None,x=0,y=0,z=0)
0
sage: x.subs(None,x=z,y=x,z=y)
z
sage: x.subs(None,x=x,y=y,z=z)
x
```

And the following also works

```sage: x.subs(None,x=0,y=x,z=0)
0
sage: x.subs(None,x=0,y=y,z=0)
0
sage: x.subs(None,x=0,y=z,z=0)
0
sage: x.subs(None,x=y,y=z,z=0)
y
sage: x.subs(None,x=y,y=0,z=0)
y
sage: x.subs(None,x=z,y=0,z=0)
z
```

Original report

The following code gives a coredump in Sage-6.5.rc3:

```a11,a12,a13,a21,a22,a23,a31,a32,a33 = allvars = var("a11,a12,a13,a21,a22,a23,a31,a32,a33")
P=PolynomialRing(QQ,allvars,order='degrevlex')
P.inject_variables()
A=matrix([[a11,a12,a13,],[a21,a22,a23,],[a31,a32,a33]])
A.subs(a11=a13,a21=-a23,a31=a33,a22=0)
```

### comment:1 Changed 6 years ago by vdelecroix

Hello,

This is actually unrelated to matrices

```sage: a22.subs(None,a11=a13,a21=-a23,a31=a33,a22=0)
...
------------------------------------------------------------------------
Unhandled SIGSEGV: A segmentation fault occurred in Sage.
This probably occurred because a *compiled* component of Sage has a bug
in it and is not properly wrapped with sig_on(), sig_off().
Sage will now terminate.
------------------------------------------------------------------------
```

(and as a sided remark, it is useless to declare the variables with `var`; the command `var` creates variables in the symbolic ring which have nothing to do with the variables of the polynomial ring)

Vincent

### comment:2 Changed 5 years ago by vdelecroix

Simpler examples with three variables `R.<x,y,z> = QQ[]`

```sage: x.subs(None,y=x,x=0,z=y)
sage: x.subs(None,x=0,y=x,z=x)
sage: x.subs(None,x=0,y=0,z=x)
```

### comment:3 Changed 5 years ago by vdelecroix

• Description modified (diff)
• Milestone changed from sage-6.5 to sage-6.10
• Priority changed from minor to critical

### comment:4 Changed 5 years ago by vdelecroix

• Summary changed from crash in matrix.subs to crash in multipolynomial substitutions

### comment:5 Changed 5 years ago by vdelecroix

• Authors set to Vincent Delecroix
• Branch set to u/vdelecroix/17785
• Commit set to f1d8e8486b815f134eda82bc726bd97964d5c0df
• Status changed from new to needs_review

New commits:

 ​f1d8e84 `Trac 17785: fix segmentation fault for subs`

### comment:6 Changed 5 years ago by vbraun

• Reviewers set to Volker Braun
• Status changed from needs_review to positive_review

### comment:7 Changed 5 years ago by vbraun

• Branch changed from u/vdelecroix/17785 to f1d8e8486b815f134eda82bc726bd97964d5c0df
• Resolution set to fixed
• Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.