On Sun, Apr 5, 2009 at 1:13 AM, Carl Witty <carl.wi...@gmail.com> wrote:
>
> On Sun, Apr 5, 2009 at 12:33 AM, jeffblakeslee <jeffb...@gmail.com> wrote:
>>
>> Here's how I got it.  Ctrl-c after a couple seconds on the first one,
>> and then try the next.
>> ----------------------------------------------------------------------
>> | SAGE Version 3.0.6, Release Date: 2008-07-30                       |
>> | Type notebook() for the GUI, and license() for information.        |
>> ----------------------------------------------------------------------
>>
>> sage: pi.n(9999999)
>> ^C
> ...
>> sage: pi.n(999)
>
> 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
>

I've made this trac #5689:

http://trac.sagemath.org/sage_trac/ticket/5689

William

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to