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

vectors over GF(2, impl='ntl') are crashing Sage #36361

Open
2 tasks done
dimpase opened this issue Sep 29, 2023 · 3 comments
Open
2 tasks done

vectors over GF(2, impl='ntl') are crashing Sage #36361

dimpase opened this issue Sep 29, 2023 · 3 comments

Comments

@dimpase
Copy link
Member

dimpase commented Sep 29, 2023

Steps To Reproduce

sage: F = GF(2, impl='ntl')
sage: m_ntl = identity_matrix(1, F)
sage: v_ntl = vector(F, (1,))
# Now consider
sage: m_ntl * v_ntl # gives an allocation error
sage: v_ntl * m_ntl # segfaults

Expected Behavior

it should not crash, it should work.

Actual Behavior

it crashes

Additional Information

reported in
https://groups.google.com/g/sage-devel/c/uSdcoZh6mH8/m/UYP-4DpnHAAJ

Environment

- **OS**: macOS, Linux 
- **Sage Version**: recent betas (10.2.beta2+)

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide
@dimpase dimpase added the t: bug label Sep 29, 2023
@dimpase
Copy link
Member Author

dimpase commented Sep 29, 2023

┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 10.2.beta4, Release Date: 2023-09-24              │
│ Using Python 3.11.5. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Warning: this is a prerelease version, and it may be unstable.     ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
sage: sage: F = GF(2, impl='ntl')
....: sage: m_ntl = identity_matrix(1, F)
....: sage: v_ntl = vector(F, (1,))
sage: m_ntl * v_ntl
---------------------------------------------------------------------------
SignalError                               Traceback (most recent call last)
Cell In [2], line 1
----> 1 m_ntl * v_ntl

File /mnt/opt/Sage/sage-dev/src/sage/structure/element.pyx:4099, in sage.structure.element.Matrix.__mul__()
   4097 
   4098         if BOTH_ARE_ELEMENT(cl):
-> 4099             return coercion_model.bin_op(left, right, mul)
   4100 
   4101         cdef long value

File /mnt/opt/Sage/sage-dev/src/sage/structure/coerce.pyx:1222, in sage.structure.coerce.CoercionModel.bin_op()
   1220 if action is not None:
   1221     if (<Action>action)._is_left:
-> 1222         return (<Action>action)._act_(x, y)
   1223     else:
   1224         return (<Action>action)._act_(y, x)

File /mnt/opt/Sage/sage-dev/src/sage/matrix/action.pyx:328, in sage.matrix.action.MatrixVectorAction._act_()
    326     else:
    327         v = v.dense_vector()
--> 328 return A._matrix_times_vector_(v)
    329 
    330 

File /mnt/opt/Sage/sage-dev/src/sage/matrix/matrix_mod2_dense.pyx:613, in sage.matrix.matrix_mod2_dense.Matrix_mod2_dense._matrix_times_vector_()
    611     return VS.zero()
    612 cdef Vector_mod2_dense c = Vector_mod2_dense.__new__(Vector_mod2_dense)
--> 613 sig_str("matrix allocation failed")
    614 c._init(self._nrows, VS)
    615 if c._entries.nrows and c._entries.ncols:

SignalError: matrix allocation failed
sage: 

and

sage: v_ntl*m_ntl
------------------------------------------------------------------------
/mnt/opt/Sage/sage-dev/local/var/lib/sage/venv-python3.11/lib/python3.11/site-packages/cysignals/signals.cpython-311-x86_64-linux-gnu.so(+0x81db)[0x7f39cb0f71db]
/mnt/opt/Sage/sage-dev/local/var/lib/sage/venv-python3.11/lib/python3.11/site-packages/cysignals/signals.cpython-311-x86_64-linux-gnu.so(+0x8288)[0x7f39cb0f7288]
/mnt/opt/Sage/sage-dev/local/var/lib/sage/venv-python3.11/lib/python3.11/site-packages/cysignals/signals.cpython-311-x86_64-linux-gnu.so(+0x9c10)[0x7f39cb0f8c10]
/lib64/libc.so.6(+0x39660)[0x7f39d8cf0660]
/mnt/opt/Sage/sage-dev/src/sage/modules/free_module_element.cpython-311-x86_64-linux-gnu.so(__pyx_f_4sage_7modules_19free_module_element_31FreeModuleElement_generic_dense__add_+0xaa)[0x7f387f644eea]
/mnt/opt/Sage/sage-dev/src/sage/structure/element.cpython-311-x86_64-linux-gnu.so(+0x17993)[0x7f39ca260993]
/usr/lib64/libpython3.11.so.1.0(PyNumber_Add+0x99)[0x7f39d90109a9]
/usr/lib64/libpython3.11.so.1.0(+0x25356c)[0x7f39d912856c]
/usr/lib64/libpython3.11.so.1.0(+0x1ac262)[0x7f39d9081262]
/mnt/opt/Sage/sage-dev/src/sage/matrix/matrix0.cpython-311-x86_64-linux-gnu.so(+0xf76f)[0x7f387ce0d76f]
...

@videlec

@jhpalmieri
Copy link
Member

This may work with sparse matrices: the problem may only exist for dense matrices (in case this helps to track down the problem).

@dimpase
Copy link
Member Author

dimpase commented Oct 8, 2023

Indeed, if m_ntl is sparse, this all works just fine.

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

3 participants