Opened 10 years ago
Last modified 7 years ago
#12032 new defect
Symbolics code passes ungrammatical expressions to maxima
Reported by: | nbruin | Owned by: | burcin |
---|---|---|---|
Priority: | major | Milestone: | sage-6.4 |
Component: | symbolics | Keywords: | |
Cc: | Merged in: | ||
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
Eviatar reports sage-devel thread:
sage: find_maximum_on_interval(-x^2 + 9*x, 4.4, 8) RuntimeError: ECL says: THROW: The catch MACSYMA-QUIT is undefined.
A little investigation with pdb.pm()
shows that the error occurs in sage.interfaces.maxima_lib line 420
if statement: result = ((result + '\n') if result else '') + max_to_string(maxima_eval("#$%s$"%statement))
where statement
has the value
'is (-20.247454751128636=-20.249999999999996<=-20.199549540424666)'
which is not a valid Maxima expression. The real error is in the code that causes this to happen.
The function maxima_eval is an ECL function, so its parameter gets converted by ECL-lib, outside maxima_lib's control. The string contains a #$...$
reader-macro, which causes the maxima-parser to handle the string. It finds the syntax error and signals it by throwing an uncaught "catch".
Invoking maxima_eval this way isn't particularly wrong, but one should ensure that the expression passed in is at least syntactically correct. If an error condition arises when *evaluating* the expression using maxima_eval
, errors are caught more gracefully.
Digging a little deeper shows that find_maximum
should not be called with symbolic arguments, so this particular error could be caught earlier. However, I think the symptom shows that the symbolics code should vet its expression a little better before passing it to maxima: The expression isn't accepted by maxima as grammatical.
Change History (5)
comment:1 Changed 9 years ago by
comment:2 Changed 8 years ago by
- Milestone changed from sage-5.11 to sage-5.12
comment:3 Changed 8 years ago by
- Milestone changed from sage-6.1 to sage-6.2
comment:4 Changed 7 years ago by
- Milestone changed from sage-6.2 to sage-6.3
comment:5 Changed 7 years ago by
- Milestone changed from sage-6.3 to sage-6.4
This bug was rediscovered in this sage-devel thread. A little further debugging uncovered some further details there: