#5689: hitting control c while computing pi results in wrong answers later
------------------------------+---------------------------------------------
Reporter: was | Owner: somebody
Type: defect | Status: new
Priority: major | Milestone: sage-3.4.1
Component: basic arithmetic | Keywords:
------------------------------+---------------------------------------------
{{{
D-69-91-159-159:~ wstein$ sage
----------------------------------------------------------------------
| Sage Version 3.4, Release Date: 2009-03-11 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
sage: RealField(10^6).pi()
^C---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call
last)
/Users/wstein/.sage/temp/D_69_91_159_159.dhcp4.washington.edu/27480/_Users_wstein__sage_init_sage_0.py
in <module>()
KeyboardInterrupt:
sage: RealField(10^3).pi()
3.14159265358979323851280895940618620443274267017841339111328125000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
}}}
Jeff Blakeslee reported this.
Cwitty followed up with:
{{{
Oh, interesting! I've always worried about _sig_on/_sig_off, but this
is the first reproducible bug I've seen them cause.
When Sage is computing pi to many digits (and in many other cases), it
sets up a signal handler; if you press Control-C, then it will longjmp
out of the signal handler. This lets you interrupt long-running
computations, but it's a really nasty thing to do... you can easily
get memory leaks, and I can imagine lots of (somewhat unlikely)
situations where you would crash Sage or get wrong answers.
I'm not sure what to do about the problem, though. The "right" fix is
to go through all the C libraries that Sage calls, and add periodic
checks for Control-C; but that's pretty impractical. Another
possibility would be to disable _sig_on, so that Control-C doesn't
work in long-running C computations. This would fix the bug, but it
would also be vastly annoying.
One workaround that might fix this particular problem is to catch
KeyboardInterrupt exceptions in the .pi() method (and in
.euler_constant(), .catalan_constant(), and .log2()), and call
mpfr_free_cache() if one is seen. Hopefully then MPFR would no longer
believe it has a higher precision value computed than it actually does
have.
Carl
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/5689>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---