Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using symbolic variables in domain 'positive' makes Sage crash #22857

Closed
egourgoulhon opened this issue Apr 22, 2017 · 21 comments
Closed

Using symbolic variables in domain 'positive' makes Sage crash #22857

egourgoulhon opened this issue Apr 22, 2017 · 21 comments

Comments

@egourgoulhon
Copy link
Member

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.

CC: @rwst @sagetrac-tmonteil @slel

Component: symbolics

Author: Dave Morris

Branch/Commit: 4cbf230

Reviewer: Eric Gourgoulhon, Thierry Monteil

Issue created by migration from https://trac.sagemath.org/ticket/22857

@mforets
Copy link
Mannequin

mforets mannequin commented Apr 22, 2017

comment:2

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

@sagetrac-tmonteil

This comment has been minimized.

@nbruin
Copy link
Contributor

nbruin commented Apr 22, 2017

comment:4

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)

@rwst
Copy link

rwst commented Apr 23, 2017

comment:5

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

@rwst
Copy link

rwst commented Apr 23, 2017

comment:6

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: 

@egourgoulhon
Copy link
Member Author

comment:7

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

@mkoeppe
Copy link
Contributor

mkoeppe commented Jul 6, 2020

comment:8

Still there in 9.2.beta3

@mkoeppe mkoeppe modified the milestones: sage-8.0, sage-9.2 Jul 6, 2020
@mkoeppe
Copy link
Contributor

mkoeppe commented Aug 13, 2020

comment:9

Still in 9.2.beta8

@mkoeppe
Copy link
Contributor

mkoeppe commented Aug 29, 2020

comment:10

Looks like this was fixed by #30063

@mkoeppe mkoeppe removed this from the sage-9.2 milestone Aug 29, 2020
@egourgoulhon
Copy link
Member Author

comment:11

Replying to @mkoeppe:

Looks like this was fixed by #30063

Indeed, the bug is no longer there in Sage 9.2.beta10.

@egourgoulhon
Copy link
Member Author

Reviewer: Eric Gourgoulhon

@slel
Copy link
Member

slel commented Aug 30, 2020

comment:13

No doctest was added for this at #30063. We should add one here.

@slel slel added this to the sage-9.2 milestone Aug 30, 2020
@mkoeppe mkoeppe removed this from the sage-9.2 milestone Oct 24, 2020
@mkoeppe mkoeppe added this to the sage-9.3 milestone Oct 24, 2020
@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 13, 2021

comment:15

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.

@mkoeppe mkoeppe modified the milestones: sage-9.3, sage-9.4 Feb 13, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.4, sage-9.5 Aug 22, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.5, sage-9.6 Dec 18, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.6, sage-9.7 May 3, 2022
@DaveWitteMorris
Copy link
Member

Branch: public/22857

@DaveWitteMorris
Copy link
Member

comment:20

The commit just adds a doctest to make sure the problem doesn't come back.


New commits:

4cbf230doctest for trac 22857

@DaveWitteMorris
Copy link
Member

Author: Dave Morris

@DaveWitteMorris
Copy link
Member

Commit: 4cbf230

@sagetrac-tmonteil
Copy link
Mannequin

sagetrac-tmonteil mannequin commented Jul 24, 2022

Changed reviewer from Eric Gourgoulhon to Eric Gourgoulhon, Thierry Monteil

@sagetrac-tmonteil
Copy link
Mannequin

sagetrac-tmonteil mannequin commented Jul 24, 2022

comment:21

LGTM.

@DaveWitteMorris
Copy link
Member

comment:22

Thanks!

@vbraun
Copy link
Member

vbraun commented Aug 1, 2022

Changed branch from public/22857 to 4cbf230

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants