Ticket #1374 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

[with patch] segfault in coercion with matrices and ints

Reported by: craigcitro Owned by: robertwb
Priority: critical Milestone: sage-2.8.15
Component: coercion Keywords:
Cc: Author(s):
Report Upstream: Reviewer(s):
Merged in: Work issues:

Description

This is the bug that was causing #1231; the fix there was easy, but as cwitty points out, the underlying bug is still there. It's something specifically to do with an entry becoming 0 in a matrix. I haven't looked into this at all; it's probably easy pickings for someone who knows the coercion code.

Here's a sample session:

sage: M = MatrixSpace(GF(5),2,2)

sage: A = M([1,0,0,1])

sage: A - int(-1)
 
[2 0]
[0 2]

sage: B = M([4,0,0,1])

sage: B - int(-1)


------------------------------------------------------------
Unhandled SIGBUS: A bus error occured in SAGE.
This probably occured because a *compiled* component
of SAGE has a bug in it (typically accessing invalid memory)
or is not properly wrapped with _sig_on, _sig_off.
You might want to run SAGE under gdb with 'sage -gdb' to debug this.
SAGE will now terminate (sorry).
------------------------------------------------------------


Attachments

trac-1374.patch Download (1.4 KB) - added by was 2 years ago.
1374-part2.patch Download (1.5 KB) - added by cwitty 2 years ago.

Change History

Changed 2 years ago by craigcitro

  • owner changed from somebody to robertwb
  • component changed from basic arithmetic to coercion

Changed 2 years ago by was

First obvious thing to do (on sage.math):

sage: matrix(GF(5), 2, [4,0,0,1]) - int(-1)

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 47703056093024 (LWP 5657)]
__pyx_f_4sage_5rings_11integer_mod_15NativeIntStruct_lookup (__pyx_v_self=0x2b62cd298e30, __pyx_v_value=5)
    at sage/rings/integer_mod.c:2750
2750      Py_INCREF(__pyx_1);

Changed 2 years ago by was

  • priority changed from major to critical
  • milestone set to sage-2.9

Changed 2 years ago by was

The problem is very likely related to this:

sage: matrix(GF(5),2, [4,0,0,1]).parent()(int(6))
[6 0]
[0 6]

This is over GF(5), so we should not see 6!

Changed 2 years ago by was

sage: m = matrix(GF(5),2, [4,0,0,1])
sage: a = matrix(GF(5),2, [4,0,0,1]).parent()(int(7))
sage: m[1,1]
1
sage: a[1,1]
7
sage: m[1,1] - a[1,1]


------------------------------------------------------------
Unhandled SIGBUS: A bus error occured in SAGE.

Changed 2 years ago by was

Changed 2 years ago by was

  • milestone changed from sage-2.9 to sage-2.8.15

Changed 2 years ago by mabshoff

  • status changed from new to closed
  • resolution set to fixed

Merged in 2.8.15.rc0.

Changed 2 years ago by cwitty

Changed 2 years ago by cwitty

  • status changed from closed to reopened
  • resolution fixed deleted
  • summary changed from segfault in coercion with matrices and ints to [with patch] segfault in coercion with matrices and ints

It's good that we don't crash any more; but maybe we should also give the right answer? :)

I think we also need to apply my 1374-part2.patch

Changed 2 years ago by mabshoff

  • status changed from reopened to closed
  • resolution set to fixed

Merged cwitty's patch in 2.8.15.rc0. All doctests pass.

Cheers,

Michael

Note: See TracTickets for help on using tickets.