#9880: Segfault in PyNaC 0.2.0.p4
-------------------------+--------------------------------------------------
Reporter: jpflori | Owner: burcin
Type: defect | Status: new
Priority: major | Milestone: sage-4.6
Component: symbolics | Keywords: pynac
Author: | Upstream: N/A
Reviewer: | Merged:
Work_issues: |
-------------------------+--------------------------------------------------
Old description:
> Here is a short example found by Burcin and reproducing the bug:
>
> {{{
> b = [var('b_%s'%i) for i in range(4)]
>
> precomp = (2^b_2 + 2)*(2^b_1 + 2^(-b_1) + 2^b_1*2^b_0 - 2^b_1*2^(-b_0)
> - 2^(-b_1)*2^b_0 - 2^(-b_1)*2^(-b_0) + 2^b_0 + 2^(-b_0) - 9) + (2^b_1 +
> 2^(-b_1) + 2^b_1*2^b_0 - 2^b_1*2^(-b_0) - 2^(-b_1)*2^b_0 -
> 2^(-b_1)*2^(-b_0) + 2^b_0 + 2^(-b_0) - 9)/2^b_2
>
> repl_dict = {b_0: b_0, b_3: b_1, b_2: b_3, b_1: b_2}
> P = precomp.substitute(repl_dict)
> P.expand()
> }}}
>
> This is already being discussed here:
> http://groups.google.com/group/sage-
> support/browse_thread/thread/7c85f02c76012722
New description:
Here is a short example found by Burcin and reproducing the bug:
{{{
b = [var('b_%s'%i) for i in range(4)]
precomp = (2^b_2 + 2)*(2^b_1 + 2^(-b_1) + 2^b_1*2^b_0 - 2^b_1*2^(-b_0)
- 2^(-b_1)*2^b_0 - 2^(-b_1)*2^(-b_0) + 2^b_0 + 2^(-b_0) - 9) + (2^b_1 +
2^(-b_1) + 2^b_1*2^b_0 - 2^b_1*2^(-b_0) - 2^(-b_1)*2^b_0 -
2^(-b_1)*2^(-b_0) + 2^b_0 + 2^(-b_0) - 9)/2^b_2
repl_dict = {b_0: b_0, b_3: b_1, b_2: b_3, b_1: b_2}
P = precomp.substitute(repl_dict)
P.expand()
}}}
This is already being discussed here: http://groups.google.com/group/sage-
support/browse_thread/thread/7c85f02c76012722
--
Comment(by jpflori):
The bug happened because of the comparison functions which are used in a
call to std::sort.
I have finally looked at the comparison functions and exchanging :
{{{
cmpval = seq[0].coeff.compare(other.exponent);
}}}
by
{{{
cmpval = -seq[0].coeff.compare(other.exponent);
}}}
in mul::compare_pow (mul.cpp:1265) seems to prevent the above bug from
happening.
It seems to fit better with the change made by William Stein in
power::compare_same_type (power.cpp:951).
However it doesn't mean the problem is completely solved...
I'll try to take a deeper look at the comparison functions at some point.
I tested the above fix with pynac 0.2.1.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/9880#comment:2>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.