Opened 11 years ago

Closed 10 years ago

#10901 closed defect (fixed)

segfault in roots() in wrong ring

Reported by: dsm Owned by: AlexGhitza
Priority: major Milestone: sage-5.0
Component: algebra Keywords:
Cc: mjo Merged in: sage-5.0.beta14
Authors: Alex Ghitza Reviewers: Michael Orlitzky
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

If you pass .roots() a ring that it can't handle, usually you get a nice exception, but in some cases it segfaults [4.6.2, OS X 10.6.6]:

sage: var("a")
a
sage: R.<x> = SR[]
sage: f = x-a
sage: parent(f)
Univariate Polynomial Ring in x over Symbolic Ring
sage: f.roots(RR)

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: 13 at address: 0x0000000000000000
0x0000000103c811f5 in mpfr_clear ()
(gdb) bt
#0  0x0000000103c811f5 in mpfr_clear ()
#1  0x0000000105440341 in __pyx_tp_dealloc_4sage_5rings_10polynomial_26polynomial_real_mpfr_dense_PolynomialRealDense ()
#2  0x000000010006d6f9 in type_call ()
#3  0x000000010000bc32 in PyObject_Call ()
#4  0x00000001000b333e in PyEval_EvalFrameEx ()
#5  0x00000001000b8fd2 in PyEval_EvalCodeEx ()
#6  0x000000010003af45 in function_call ()
#7  0x000000010000bc32 in PyObject_Call ()
#8  0x000000010001dc3b in instancemethod_call ()
#9  0x000000010000bc32 in PyObject_Call ()
#10 0x000000010406c46e in __pyx_f_4sage_9structure_11coerce_maps_24DefaultConvertMap_unique__call_ ()
#11 0x000000010232f690 in __pyx_pf_4sage_9structure_6parent_6Parent___call__ ()
#12 0x000000010000bc32 in PyObject_Call ()
#13 0x0000000105103580 in __pyx_pf_4sage_5rings_10polynomial_18polynomial_element_10Polynomial_change_ring (__pyx_v_self=0x10cb32ae0, __pyx_v_R=<value temporarily unavailable, due to optimizations>) at sage/rings/polynomial/polynomial_element.c:16432
#14 0x000000010000bc32 in PyObject_Call ()
#15 0x0000000105152ec0 in __pyx_pf_4sage_5rings_10polynomial_18polynomial_element_10Polynomial_roots (__pyx_v_self=0x10cb32ae0, __pyx_args=<value temporarily unavailable, due to optimizations>, __pyx_kwds=<value temporarily unavailable, due to optimizations>) at sage/rings/polynomial/polynomial_element.c:31609
#16 0x00000001000b7709 in PyEval_EvalFrameEx ()
#17 0x00000001000b8fd2 in PyEval_EvalCodeEx ()
#18 0x00000001000b872e in PyEval_EvalFrameEx ()
#19 0x00000001000b8fd2 in PyEval_EvalCodeEx ()
#20 0x00000001000b6185 in PyEval_EvalFrameEx ()
#21 0x00000001000b8fd2 in PyEval_EvalCodeEx ()
#22 0x00000001000b6185 in PyEval_EvalFrameEx ()
#23 0x00000001000b7b01 in PyEval_EvalFrameEx ()
#24 0x00000001000b8fd2 in PyEval_EvalCodeEx ()
#25 0x00000001000b6185 in PyEval_EvalFrameEx ()
#26 0x00000001000b8fd2 in PyEval_EvalCodeEx ()
#27 0x00000001000b6185 in PyEval_EvalFrameEx ()
#28 0x00000001000b8fd2 in PyEval_EvalCodeEx ()
#29 0x00000001000b6185 in PyEval_EvalFrameEx ()
#30 0x00000001000b8fd2 in PyEval_EvalCodeEx ()
#31 0x00000001000b90b6 in PyEval_EvalCode ()
#32 0x00000001000dde5e in PyRun_FileExFlags ()
#33 0x00000001000de119 in PyRun_SimpleFileExFlags ()
#34 0x00000001000eb61b in Py_Main ()
#35 0x0000000100000f14 in start ()

and similarly for CC.

[Not sure which component this falls under; anyone who knows, please change.]

Attachments (1)

trac10901.patch (2.3 KB) - added by AlexGhitza 10 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 11 years ago by johanbosman

  • Component changed from PLEASE CHANGE to algebra
  • Milestone set to sage-4.7
  • Owner changed from tbd to AlexGhitza
  • Priority changed from minor to major

The patch in #9826 fixes this.

comment:2 Changed 10 years ago by johanbosman

  • Milestone changed from sage-5.0 to sage-duplicate/invalid/wontfix
  • Status changed from new to needs_review

In the meantime, this seems to've been fixed already:

sage: sage: f.roots(RR)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
...
TypeError: Cannot evaluate symbolic expression to a numeric value.

comment:3 Changed 10 years ago by mjo

  • Cc mjo added

comment:4 Changed 10 years ago by AlexGhitza

I confirm that the issue is resolved.

I am attaching a trivial patch doctesting this so we notice if we break it again.

Changed 10 years ago by AlexGhitza

comment:5 Changed 10 years ago by mjo

  • Reviewers set to Michael Orlitzky
  • Status changed from needs_review to positive_review

comment:6 Changed 10 years ago by jdemeyer

  • Authors set to Alex Ghitza
  • Milestone changed from sage-duplicate/invalid/wontfix to sage-5.0

comment:7 Changed 10 years ago by jdemeyer

  • Merged in set to sage-5.0.beta14
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.