Opened 8 years ago
Closed 8 years ago
#13133 closed defect (fixed)
BooleanMonomial.index() SEGFAULT on constant monomials
Reported by: | Bouillaguet | Owned by: | malb |
---|---|---|---|
Priority: | minor | Milestone: | sage-5.1 |
Component: | commutative algebra | Keywords: | |
Cc: | malb, AlexanderDreyer, PolyBori | Merged in: | sage-5.1.beta6 |
Authors: | Charles Bouillaguet | Reviewers: | Alexander Dreyer |
Report Upstream: | Reported upstream. Developers acknowledge bug. | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
sage: R.<x,y> = BooleanPolynomialRing() sage: R(1).lm().index()
crashes miserably (from inside polybori, as I understand) with:
/usr/local/sage/local/lib/libcsage.so(print_backtrace+0x3b)[0x1cd9d3] /usr/local/sage/local/lib/libcsage.so(sigdie+0x17)[0x1cda13] /usr/local/sage/local/lib/libcsage.so(sage_signal_handler+0x20d)[0x1cd598] [0xc27400] /usr/local/sage/local/lib/python2.6/site-packages/sage/rings/polynomial/pbori.so(+0x13d90)[0x5235d90] /usr/local/sage/local/lib/libpython2.6.so.1.0(PyEval_EvalFrameEx+0x482e)[0x2a55ee] /usr/local/sage/local/lib/libpython2.6.so.1.0(PyEval_EvalCodeEx+0x7d1)[0x2a6fa1] /usr/local/sage/local/lib/libpython2.6.so.1.0(PyEval_EvalCode+0x63)[0x2a70c3] /usr/local/sage/local/lib/libpython2.6.so.1.0(PyEval_EvalFrameEx+0x50c9)[0x2a5e89] /usr/local/sage/local/lib/libpython2.6.so.1.0(PyEval_EvalCodeEx+0x7d1)[0x2a6fa1] /usr/local/sage/local/lib/libpython2.6.so.1.0(PyEval_EvalFrameEx+0x4370)[0x2a5130] /usr/local/sage/local/lib/libpython2.6.so.1.0(PyEval_EvalCodeEx+0x7d1)[0x2a6fa1] /usr/local/sage/local/lib/libpython2.6.so.1.0(PyEval_EvalFrameEx+0x4370)[0x2a5130] /usr/local/sage/local/lib/libpython2.6.so.1.0(PyEval_EvalFrameEx+0x59e1)[0x2a67a1] /usr/local/sage/local/lib/libpython2.6.so.1.0(PyEval_EvalCodeEx+0x7d1)[0x2a6fa1] /usr/local/sage/local/lib/libpython2.6.so.1.0(PyEval_EvalFrameEx+0x4370)[0x2a5130] /usr/local/sage/local/lib/libpython2.6.so.1.0(PyEval_EvalCodeEx+0x7d1)[0x2a6fa1] /usr/local/sage/local/lib/libpython2.6.so.1.0(PyEval_EvalFrameEx+0x4370)[0x2a5130] /usr/local/sage/local/lib/libpython2.6.so.1.0(PyEval_EvalCodeEx+0x7d1)[0x2a6fa1] /usr/local/sage/local/lib/libpython2.6.so.1.0(PyEval_EvalFrameEx+0x4370)[0x2a5130] /usr/local/sage/local/lib/libpython2.6.so.1.0(PyEval_EvalCodeEx+0x7d1)[0x2a6fa1] /usr/local/sage/local/lib/libpython2.6.so.1.0(PyEval_EvalCode+0x63)[0x2a70c3] /usr/local/sage/local/lib/libpython2.6.so.1.0(PyRun_FileExFlags+0xb1)[0x2c6f91] /usr/local/sage/local/lib/libpython2.6.so.1.0(PyRun_SimpleFileExFlags+0xdc)[0x2c71cc] /usr/local/sage/local/lib/libpython2.6.so.1.0(PyRun_AnyFileExFlags+0x7a)[0x2c75fa] /usr/local/sage/local/lib/libpython2.6.so.1.0(Py_Main+0xc7d)[0x2d3c4d] python(main+0x27)[0x8048657] /lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0x405113] ------------------------------------------------------------------------ Unhandled SIGSEGV: A segmentation fault 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 seems to be a bug in PolyBori?. The patch I propose just checks that the monomial is not constant before calling the polybori function. This is a workaround though
Attachments (1)
Change History (8)
comment:1 Changed 8 years ago by
comment:2 follow-up: ↓ 3 Changed 8 years ago by
- Report Upstream changed from Not yet reported upstream; Will do shortly. to Reported upstream. Developers acknowledge bug.
I expected the bug to also occur with the zero monomial, and there is no is_constant() method that I could have used. However, the bug does not occur with zero, because "zero" is not a monomial :
sage: R(0).lm().parent() Boolean PolynomialRing in x, y sage: R(1).lm().parent() MonomialMonoid of Boolean PolynomialRing in x, y
I wonder if this behavior is the best possible, but it does make sense. Patch updated
comment:3 in reply to: ↑ 2 Changed 8 years ago by
- Status changed from new to needs_review
Replying to Bouillaguet:
I expected the bug to also occur with the zero monomial, and there is no is_constant() method that I could have used. However, the bug does not occur with zero, because "zero" is not a monomial :
This is exactly the reason why there is no is_constant()
routine.
sage: R(0).lm().parent() Boolean PolynomialRing in x, y sage: R(1).lm().parent() MonomialMonoid of Boolean PolynomialRing in x, yI wonder if this behavior is the best possible, but it does make sense. Patch updated
This is the best compromise: PolyBoRi's original interface throws a ValueError? when accessing zero polynomial leading monomials. (As you pointed out, there are no zero monomials.) But this would not be consistent with other polynomial types in Sage (e. g. Singular polynomials used for QQ[]
). But these return polynomials (not monomials) anyway, so zero is not an issue there.
The patch is fine, I'll give it a positive review and update the pending spkg for PolyBoRi 0.8.2 at #13124 soon.
comment:4 Changed 8 years ago by
- Reviewers set to Alexander Dreyer
- Status changed from needs_review to positive_review
comment:5 Changed 8 years ago by
I also fixed #13124 accordingly. Without your patch, we'd have this then:
sage: R.<x,y> = BooleanPolynomialRing() sage: R(1).lm().index() 2147483647
(final line platform dependent)
comment:6 Changed 8 years ago by
- Dependencies polybori deleted
comment:7 Changed 8 years ago by
- Merged in set to sage-5.1.beta6
- Resolution set to fixed
- Status changed from positive_review to closed
Confirmed, this is a bug of both Sage's interface (it should not call
firstIndex()
in this case) as well as upstream PolyBoRi (it should not crash on inconsistent user commands). The patch solved the problem very well, but you should useis_one()
instead ofdegree()==0
. This performs better (degree() needs to count first).