Changes between Version 6 and Version 8 of Ticket #14211


Ignore:
Timestamp:
05/03/15 08:53:29 (6 years ago)
Author:
rws
Comment:

Minimal case given. In Sage hash(matrix()) will not allow hashing probably because PyObject_Hash will fail and to prevent that. The fail happens in Pynac nevertheless because the check is avoided due to function expansion and there leads to the crash.

One part of the fix is preventing Sage from crashing. Surrounding the call to Pynac in Expression::__nonzero__ with guards:

            sig_on()
            pynac_result = relational_to_bool(self._gobj)
            sig_off()

leads to:

sage: bool(f(x)==f(x))
terminate called after throwing an instance of 'std::runtime_error'
  what():  Number_T::hash() python function (__hash__) raised exception
---------------------------------------------------------------------------
TypeError: mutable matrices are unhashable

which is the same you get with hash(matrix()), so quite sensible. What more? Why are matrices generated by vector*vector (the original case) or those in a function definition (like above) mutable at all?

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #14211

    • Property Report Upstream changed from N/A to Reported upstream. Developers acknowledge bug.
    • Property Milestone changed from sage-6.5 to sage-6.7
  • Ticket #14211 – Description

    v6 v8  
    11{{{
    2 sage: pU = vector([0,0])                           
    3 sage: pB = vector([2,0])                           
    4 sage: f1(tau) = (pU + (tau - 1)*(pB - pU)).row()*(pU + (tau - 1)*(pB - pU)).column()                                         
    5 sage: d = (pB-pU).row()*(pB-pU).column()                                                             
    6 sage: f2(tau) = tau^2 * d + 2*tau*(pU.row()*(pB-pU).column() - d) + (pB-2*pU).row()*(pB-2*pU).column()
    7 sage: bool(f1(x) == f2(x))
     2sage: f(x)=matrix()                           
     3sage: bool(f(x)==f(x))
     4
    85terminate called after throwing an instance of 'std::runtime_error'
    96  what():  Number_T::hash() python function (__hash__) raised exception