You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
gh-39293: Fix segmentation fault in singular interface code
Fixes#36101
### 📝 Checklist
<!-- Put an `x` in all the boxes that apply. -->
- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.
### ⌛ Dependencies
<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - #12345: short description why this is a dependency -->
<!-- - #34567: ... -->
URL: #39293
Reported by: user202729
Reviewer(s): Marc Mezzarobba
Copy file name to clipboardExpand all lines: src/sage/libs/singular/singular.pyx
+11-8Lines changed: 11 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -1393,6 +1393,13 @@ cdef number *sa2si_NF(object elem, ring *_ring) noexcept:
1393
1393
(a + 1)
1394
1394
sage: R(F.gen()^5) + 1
1395
1395
(-a^2 + a + 2)
1396
+
1397
+
Ensures :issue:`36101` is fixed::
1398
+
1399
+
sage: RR.<x, y, r, s0, c0, s1, c1> = AA[]
1400
+
sage: f = -4*r^2+(((1+2*AA(cos(pi/6)))*c0*r+2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2+((1-(1+2*AA(cos(pi/6)))*c0*r-2*c1*r+(1+2*AA(cos(pi/6)))*s0*r+2*s1*r)/2-1/2)^2
1401
+
sage: f.change_ring( QuadraticField(3) )
1402
+
...
1396
1403
"""
1397
1404
cdef int i
1398
1405
cdef number *n1
@@ -1403,13 +1410,6 @@ cdef number *sa2si_NF(object elem, ring *_ring) noexcept:
1403
1410
cdef number *apow1
1404
1411
cdef number *apow2
1405
1412
1406
-
cdef nMapFunc nMapFuncPtr =NULL
1407
-
1408
-
nMapFuncPtr = naSetMap(_ring.cf, currRing.cf) # choose correct mapping function
1409
-
1410
-
if nMapFuncPtr isNULL:
1411
-
raiseRuntimeError("Failed to determine nMapFuncPtr")
1412
-
1413
1413
elem =list(elem)
1414
1414
1415
1415
if _ring != currRing:
@@ -1432,7 +1432,10 @@ cdef number *sa2si_NF(object elem, ring *_ring) noexcept:
1432
1432
rComplete(qqr,1)
1433
1433
qqr.ShortOut =0
1434
1434
1435
-
nMapFuncPtr = naSetMap(qqr.cf, _ring.cf) # choose correct mapping function
1435
+
assert _ring.cf.type == n_algExt # if false naSetMap will segmentation fault (should never happen)
0 commit comments