Segfault while creating finite field homomorphism

21 views
Skip to first unread message

Jean-Pierre Flori

unread,
May 27, 2011, 8:08:05 AM5/27/11
to sage-support
On my computer I get a segfault just doing :
----------------------------------------------------------------------
| Sage Version 4.7.rc1, Release Date: 2011-04-30 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
**********************************************************************
* *
* Warning: this is a prerelease version, and it may be unstable. *
* *
**********************************************************************
sage: K = GF(1<<16,'a'); L = GF(1<<32,'b')
sage: K.Hom(L)[0]
Finite Field in a of size 2^16
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libcsage.so(print_backtrace
+0x31)[0x7f86df446df2]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libcsage.so(sigdie+0x14)
[0x7f86df446e24]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/
libcsage.so(sage_signal_handler+0x1d3)[0x7f86df446a39]
/lib/libpthread.so.0(+0xef60)[0x7f86e48b2f60]
/lib/libc.so.6(gsignal+0x35)[0x7f86e3eeb165]
/lib/libc.so.6(abort+0x180)[0x7f86e3eedf70]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libcsage.so(init_csage+0x0)
[0x7f86df4478ac]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libntl.so(_ZN3NTL5ErrorEPKc
+0x1f)[0x7f86dec3d35f]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/
libntl.so(_ZN3NTL5buildERNS_12GF2XArgumentERKNS_4GF2XERKNS_11GF2XModulusEl
+0xb4)[0x7f86deb66b74]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/
libntl.so(_ZN3NTL13ProjectPowersERNS_4GF2XERKS0_lS3_RKNS_11GF2XModulusE
+0xab)[0x7f86deb677ab]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/
libntl.so(_ZN3NTL12DoMinPolyModERNS_4GF2XERKS0_RKNS_11GF2XModulusElS3_
+0x37)[0x7f86deb68117]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/
libntl.so(_ZN3NTL12IrredPolyModERNS_4GF2XERKS0_RKNS_11GF2XModulusEl
+0x53)[0x7f86deb685f3]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/python2.6/site-packages/
sage/rings/finite_rings/element_ntl_gf2e.so(+0xe7f3)[0x7f86ca3897f3]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyObject_Call+0x53)[0x7f86e4b0acf3]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/python2.6/site-packages/
sage/rings/finite_rings/element_ntl_gf2e.so(+0xf706)[0x7f86ca38a706]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyObject_Call+0x53)[0x7f86e4b0acf3]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/python2.6/site-packages/
sage/rings/finite_rings/finite_field_base.so(+0xdbbd)[0x7f86cffc5bbd]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyObject_Call+0x53)[0x7f86e4b0acf3]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/python2.6/site-packages/
sage/rings/morphism.so(+0xf09f)[0x7f86d597609f]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(+0xa10b8)[0x7f86e4b610b8]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyObject_Call+0x53)[0x7f86e4b0acf3]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyEval_EvalFrameEx+0x3a79)[0x7f86e4ba16a9]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyEval_EvalCodeEx+0x879)[0x7f86e4ba4839]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(+0x70c12)[0x7f86e4b30c12]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyObject_Call+0x53)[0x7f86e4b0acf3]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(+0x5794f)[0x7f86e4b1794f]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyObject_Call+0x53)[0x7f86e4b0acf3]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(+0xa54ec)[0x7f86e4b654ec]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyObject_Call+0x53)[0x7f86e4b0acf3]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyEval_CallObjectWithKeywords+0x47)[0x7f86e4b9d637]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/python2.6/site-packages/
sage/structure/parent.so(+0x13e60)[0x7f86dbf36e60]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyObject_Call+0x53)[0x7f86e4b0acf3]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyEval_CallObjectWithKeywords+0x47)[0x7f86e4b9d637]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(+0x6069a)[0x7f86e4b2069a]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyObject_Call+0x53)[0x7f86e4b0acf3]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/python2.6/site-packages/
sage/structure/parent_gens.so(+0x7753)[0x7f86d9273753]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyEval_EvalFrameEx+0x4ef5)[0x7f86e4ba2b25]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyEval_EvalFrameEx+0x5a8a)[0x7f86e4ba36ba]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyEval_EvalCodeEx+0x879)[0x7f86e4ba4839]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(+0x70b26)[0x7f86e4b30b26]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyObject_Call+0x53)[0x7f86e4b0acf3]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(+0x5794f)[0x7f86e4b1794f]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyObject_Call+0x53)[0x7f86e4b0acf3]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(+0xa3e84)[0x7f86e4b63e84]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyEval_EvalFrameEx+0x1933)[0x7f86e4b9f563]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyEval_EvalCodeEx+0x879)[0x7f86e4ba4839]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyEval_EvalCode+0x32)[0x7f86e4ba4932]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyEval_EvalFrameEx+0x4ccb)[0x7f86e4ba28fb]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyEval_EvalCodeEx+0x879)[0x7f86e4ba4839]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyEval_EvalFrameEx+0x5364)[0x7f86e4ba2f94]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyEval_EvalCodeEx+0x879)[0x7f86e4ba4839]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyEval_EvalFrameEx+0x5364)[0x7f86e4ba2f94]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyEval_EvalFrameEx+0x5a8a)[0x7f86e4ba36ba]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyEval_EvalCodeEx+0x879)[0x7f86e4ba4839]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyEval_EvalFrameEx+0x5364)[0x7f86e4ba2f94]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyEval_EvalCodeEx+0x879)[0x7f86e4ba4839]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyEval_EvalFrameEx+0x5364)[0x7f86e4ba2f94]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyEval_EvalCodeEx+0x879)[0x7f86e4ba4839]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyEval_EvalFrameEx+0x5364)[0x7f86e4ba2f94]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyEval_EvalCodeEx+0x879)[0x7f86e4ba4839]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyEval_EvalCode+0x32)[0x7f86e4ba4932]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyRun_FileExFlags+0xb0)[0x7f86e4bc6d10]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.
1.0(PyRun_SimpleFileExFlags+0xdf)[0x7f86e4bc774f]
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/libpython2.6.so.1.0(Py_Main
+0xb23)[0x7f86e4bd4a03]
/lib/libc.so.6(__libc_start_main+0xfd)[0x7f86e3ed7c4d]
python[0x4006a1]

------------------------------------------------------------------------
Unhandled SIGABRT: An abort() occurred in Sage.
This probably occurred because a *compiled* component of Sage has a
bug
in it and 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.

This does not happen for values smaller than 16, but does also happen
for bigger values.
This happens when the morphisms get checked in sage.rings.morphism at
the line:
t = parent.domain()._is_valid_homomorphism_(parent.codomain(),
im_gens)
potentially deeper.
If I add something silly as print parent.codomain() just before that
line it does not segfault anymore...

I'm using sage 4.7.rc1 on debian amd64, gcc 4.6.
Can anybody reproduce that behavior, so we should open a trac ticket ?
I could not find anything similar here or on trac.
I'll continue investigating it anyway.

Simon King

unread,
May 27, 2011, 8:27:48 AM5/27/11
to sage-support
Hi Jean-Pierre,

On 27 Mai, 14:08, Jean-Pierre Flori <jpfl...@gmail.com> wrote:

> I'm using sage 4.7.rc1 on debian amd64, gcc 4.6.
> Can anybody reproduce that behavior, so we should open a trac ticket ?
> I could not find anything similar here or on trac.
> I'll continue investigating it anyway.

I confirm the error with 4.7.rc2. So, it should be a ticket, IMO. Can
you open it?

Would people mind to make it a blocker? Segfaults are evil...

Cheers,
Simon

Jean-Pierre Flori

unread,
May 27, 2011, 8:31:00 AM5/27/11
to sage-support
I'll take care of it with a fix hopefully.
The value 16 is of course related to FF implementation.
From 16 it uses NTL and GF2X.
There's something nasty occuring in charpoly() or deeper.

Simon King

unread,
May 27, 2011, 8:49:27 AM5/27/11
to sage-support
Hi Jean-Pierre,

On 27 Mai, 14:31, Jean-Pierre Flori <jpfl...@gmail.com> wrote:
> I'll take care of it with a fix hopefully.

It turns out that the error occurs in the list() method of a homset,
which starts with

sage: K = GF(1<<16,'a'); L = GF(1<<32,'b')
sage: self = K.Hom(L)
sage: D = self.domain()
sage: C = self.codomain()
sage: f = D.modulus()
sage: g = C['x'](f)
sage: r = g.roots()

Now, the following works:
sage: for a,_ in r:
....: print a
....: t = D.hom(a,C)
....:

But this segfaults!!
sage: for a,_ in r:
....: t = D.hom(a,C)
....:

In other words, printing the elements `a` seems to initialise some
data, and without printing them data are missing, resulting in a
segfault. Or put differently, the initialisation of finite field
elements is incomplete.

By the way, the elements `a` have a custom __repr__ method - shouldn't
it be _repr_ with a single underscore?

Cheers,
Simon

Jean-Pierre Flori

unread,
May 27, 2011, 9:03:22 AM5/27/11
to sage-support
Putting sig_on/sig_off around:
sig_on()
cdef GF2X_c r = GF2X_IrredPolyMod(GF2E_rep(self.x),
GF2E_modulus())
sig_off()
I get:
/home/jp/boulot/sage/sage-4.7.rc1/local/lib/python2.6/site-packages/
sage/rings/finite_rings/element_ntl_gf2e.so in
sage.rings.finite_rings.element_ntl_gf2e.FiniteField_ntl_gf2eElement.minpoly
(sage/rings/finite_rings/element_ntl_gf2e.cpp:11156)()

RuntimeError: build GF2XArgument: bad args

What is also strange is that it only happens for the second element...

Jean-Pierre Flori

unread,
May 27, 2011, 9:22:45 AM5/27/11
to sage-support
Adding

(<FiniteField_ntl_gf2e>self._parent).F.restore()
before calling
cdef GF2X_c r = GF2X_IrredPolyMod(GF2E_rep(self.x),GF2E_modulus())
fixes everything.
Not sure yet why it does not get called before in that situation...

Jean-Pierre Flori

unread,
May 27, 2011, 9:41:34 AM5/27/11
to sage-support
I must admit that I do not know what that method call exactly does,
but calling it resolve the mentionned bug.
Moreover it is called in different places all over the file in a
similar manner so I have the feeling that it could be an acceptable
fix.
I'll open a trac ticket with that fix and a doctest hoping that
someone with a better understanding of ntl and gf2x will confirm that
it is ok or provide a correct fix.

Cheers,

Jean-Pierre Flori

unread,
May 27, 2011, 11:02:55 AM5/27/11
to sage-support
This is now Trac #11390.
Reply all
Reply to author
Forward
0 new messages