Opened 3 years ago

Last modified 10 months ago

#22857 new defect

Using symbolic variables in domain 'positive' makes Sage crash

Reported by: egourgoulhon Owned by:
Priority: major Milestone: sage-8.0
Component: symbolics Keywords:
Cc: rws Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by tmonteil)

In Sage 7.6 and 8.0.beta2, we have

sage: a, b = var('a b', domain='positive')
sage: bool((a-b)*b == 0)

;;;
;;; Detected access to protected memory, also kwown as 'bus or segmentation fault'.
;;; Jumping to the outermost toplevel prompt
;;;

Erreur de segmentation (core dumped)

This was reported on this ask question.

Change History (7)

comment:1 Changed 3 years ago by egourgoulhon

  • Cc rws added

comment:2 Changed 3 years ago by mforets

in my machine (mac osx 10.11.6) the command works in v7.5.1, but breaks in v8.0beta2.

sage: version()
'SageMath version 7.5.1, Release Date: 2017-01-15'
sage: a, b = var('a b', domain='positive')
sage: bool((a-b)*b == 0)
False
sage: version()
'SageMath version 8.0.beta2, Release Date: 2017-04-12'
sage: a, b = var('a b', domain='positive')
sage: bool((a-b)*b == 0)
;;;
;;; Detected access to protected memory, also kwown as 'bus or segmentation fault'.
;;; Jumping to the outermost toplevel prompt
;;;

Illegal instruction: 4

comment:3 Changed 3 years ago by tmonteil

  • Description modified (diff)

comment:4 Changed 3 years ago by nbruin

Can you isolate the actual sequence of maxima commands that lead to the error? Then it's possible to see if it's a bug in ECL or something in Maxima itself (the kind of error suggests it's something that is poorly handled in ECL)

comment:5 Changed 3 years ago by rws

I cannot reproduce it with:

sage: a, b = var('a b')
sage: (a>0)._maxima_init_assume_()
'(_SAGE_VAR_a)>(0)'
sage: maxima.assume(_)
[_SAGE_VAR_a>0]
sage: (b>0)._maxima_init_assume_()
'(_SAGE_VAR_b)>(0)'
sage: maxima.assume(_)
[_SAGE_VAR_b>0]
sage: bool((a-b)*b==0)
False

but I can make it disappear with:

diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx
index 01319b5e68..8522746f27 100644
--- a/src/sage/symbolic/expression.pyx
+++ b/src/sage/symbolic/expression.pyx
@@ -1786,7 +1786,7 @@ cdef class Expression(CommutativeRingElement):
             pynac_assume_rel(self._gobj)
             if str(s._sage_()[0]) in ['meaningless','inconsistent','redundant']:
                 raise ValueError("Assumption is %s" % str(s._sage_()[0]))
-            _assumptions.append(self)
+            #_assumptions.append(self)
 
     def forget(self):
         """

Anyway, with the original trigger ECL goes into an infinite loop:

#114 0x00007ffd8f408645 in L125signdiff_special (v1xlhs=0x3b56401, 
    v2xrhs=0x3b19fb1) at binary-ecl/compar.c:6765
#115 0x00007ffd8f3ffaaa in L124signdiff (v1x=<optimized out>)
    at binary-ecl/compar.c:6679
#116 0x00007ffd8f3f0bf2 in L123sign_mplus (v1x=0x3b56e81)
    at binary-ecl/compar.c:6420
#117 0x00007ffd8f409c73 in L108sign1 (v1x=<optimized out>)
    at binary-ecl/compar.c:5682
#118 0x00007ffd8f3fb620 in L104sign_ (v1x=0x3b56e81)
    at binary-ecl/compar.c:5304
#119 0x00007ffd8f408645 in L125signdiff_special (v1xlhs=0x3b19f51, 
    v2xrhs=0x5ce7180) at binary-ecl/compar.c:6765
#120 0x00007ffd8f3ffaaa in L124signdiff (v1x=<optimized out>)
    at binary-ecl/compar.c:6679
#121 0x00007ffd8f3f0bf2 in L123sign_mplus (v1x=0x3b0b1a1)
    at binary-ecl/compar.c:6420
#122 0x00007ffd8f409c73 in L108sign1 (v1x=<optimized out>)
    at binary-ecl/compar.c:5682
#123 0x00007ffd8f3fb620 in L104sign_ (v1x=0x3b0b1a1)
    at binary-ecl/compar.c:5304

comment:6 Changed 3 years ago by rws

OK here the confirmation:

sage: a, b = var('a b')
sage: (a>0)._maxima_init_assume_()
'(_SAGE_VAR_a)>(0)'
sage: maxima.assume(_)
[_SAGE_VAR_a>0]
sage: (b>0)._maxima_init_assume_()
'(_SAGE_VAR_b)>(0)'
sage: maxima.assume(_)
[_SAGE_VAR_b>0]
sage: maxima._eval_line('is (equal((_SAGE_VAR_a-_SAGE_VAR_b)*_SAGE_VAR_b,0))')

/home/ralf/sage/local/lib/python2.7/site-packages/sage/interfaces/maxima.pyc in _eval_line(self, line, allow_use_file, wait_for_prompt, reformat, error_check, restart_if_needed)
    791         assert line_echo.strip().endswith(line.strip()), 'mismatch:\n' + line_echo + line
    792 
--> 793         self._expect_expr(self._display_prompt)
    794         out = self._before()        # input echo + output prompt + output
    795         if error_check:

/home/ralf/sage/local/lib/python2.7/site-packages/sage/interfaces/maxima.pyc in _expect_expr(self, expr, timeout)
    713                 i = self._expect.expect(expr,timeout=timeout)
    714             else:
--> 715                 i = self._expect.expect(expr)
    716             if i > 0:
    717                 v = self._expect.before

/home/ralf/sage/local/lib/python2.7/site-packages/pexpect/spawnbase.pyc in expect(self, pattern, timeout, searchwindowsize, async)
    319         compiled_pattern_list = self.compile_pattern_list(pattern)
    320         return self.expect_list(compiled_pattern_list,
--> 321                 timeout, searchwindowsize, async)
    322 
    323     def expect_list(self, pattern_list, timeout=-1, searchwindowsize=-1,

/home/ralf/sage/local/lib/python2.7/site-packages/pexpect/spawnbase.pyc in expect_list(self, pattern_list, timeout, searchwindowsize, async)
    343             return expect_async(exp, timeout)
    344         else:
--> 345             return exp.expect_loop(timeout)
    346 
    347     def expect_exact(self, pattern_list, timeout=-1, searchwindowsize=-1,

/home/ralf/sage/local/lib/python2.7/site-packages/pexpect/expect.pyc in expect_loop(self, timeout)
    103                     timeout = end_time - time.time()
    104         except EOF as e:
--> 105             return self.eof(e)
    106         except TIMEOUT as e:
    107             return self.timeout(e)

/home/ralf/sage/local/lib/python2.7/site-packages/pexpect/expect.pyc in eof(self, err)
     48             if err is not None:
     49                 msg = str(err) + '\n' + msg
---> 50             raise EOF(msg)
     51 
     52     def timeout(self, err=None):

EOF: End Of File (EOF). Exception style platform.
Maxima with PID 23086 running /home/ralf/sage/local/bin/maxima --userdir=/home/ralf/.sage/maxima -p /home/ralf/sage/local/bin/sage-maxima.lisp
command: /home/ralf/sage/local/bin/maxima
args: ['/home/ralf/sage/local/bin/maxima', '--userdir=/home/ralf/.sage/maxima', '-p', '/home/ralf/sage/local/bin/sage-maxima.lisp']
buffer (last 100 chars): ''
before (last 100 chars): "y, also kwown as 'bus or segmentation fault'.\r\n;;; Jumping to the outermost toplevel prompt\r\n;;;\r\n\r\n"
after: <class 'pexpect.exceptions.EOF'>
match: None
match_index: None
exitstatus: None
flag_eof: True
pid: 23086
child_fd: 14
closed: False
timeout: None
delimiter: <class 'pexpect.exceptions.EOF'>
logfile: None
logfile_read: None
logfile_send: None
maxread: 4194304
ignorecase: False
searchwindowsize: None
delaybeforesend: None
delayafterclose: 0.1
delayafterterminate: 0.1
searcher: searcher_re:
    0: re.compile("<sage-display>")
sage: 

comment:7 Changed 10 months ago by egourgoulhon

Just to tell that the bug is still there in Sage 8.7.beta3.

Note: See TracTickets for help on using tickets.