[sage-devel] Re: using infinite recursion productively
On Friday, May 20, 2016 at 9:43:33 PM UTC+2, Nils Bruin wrote: > > On Friday, May 20, 2016 at 11:26:50 AM UTC-7, Nils Bruin wrote: >> >> sys.setrecursionlimit(5) >> > OK, patching sage.doctest.forker.init_sage to include this statements > results in: > Can we make this check part of our usual routine somewhere? > Sounds good to me! -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Re: using infinite recursion productively
On Friday, May 20, 2016 at 11:26:50 AM UTC-7, Nils Bruin wrote: > > Come to think of it, I think that flag already exists: > > sys.setrecursionlimit(5) > OK, patching sage.doctest.forker.init_sage to include this statements results in: sage -t src/sage/functions/other.py # Killed due to segmentation fault sage -t src/sage/functions/log.py # Killed due to segmentation fault sage -t src/sage/structure/coerce_dict.pyx # 2 doctests failed sage -t src/sage/rings/qqbar.py # 2 doctests failed These are tickets #20624, #20642 (convenient relation between ticket numbers!) for the first two failures. The second two fail because they actually test something about the recursion limit. Can we make this check part of our usual routine somewhere? -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Re: using infinite recursion productively
On Friday, May 20, 2016 at 9:50:05 AM UTC-7, Samuel Lelievre wrote: > > > Could you tell which two places you have in mind? > http://trac.sagemath.org/ticket/20624 http://trac.sagemath.org/ticket/10963#comment:242 In both cases, the "RuntimeError: Maximum recursion depth exceeded" was caught by a try/except of the type: There's no harm in trying this first. If it fails for any reason, we'll just try something else. (except that the first thing ended up, via very circuitous routes, coming back to the same piece of code. The problem in python is that in such a case, an infinite recursion does *not* incur a huge or particularly noticeable penalty before failing -- exactly because the depth is so severely limited. In both cases, the infinite recursions were only discovered because sometimes, a garbage collection would be triggered with an extremely filled python callstack. Then, when weakref callbacks get executed, the recursion depth exception might happen there. Of course, python can't actually raise exceptions inside the GC, so there's no choice for python but to *ignore* the exception. It does print the fact it's ignoring an exception on the stdout/stderr, though, and this is NOT prevented by the try/except. Obviously, the first time we ran into this issue, it was misdiagnosed as probably a recursion in a weakref callback handler. As a result, we now have what I think are extremely robust weakref callback handlers in some of our weak dictionaries (for instance, better than Python's standard WeakValueDictionary). Perhaps we should patch Python so that it has a flag to coredump on a recursion depth exception rather than raise a catchable exception and run the testsuite with that option every now and again. Come to think of it, I think that flag already exists: sys.setrecursionlimit(5) seems to have the desired effect (my guess it's deep enough to overflow the C call stack) Is there an easy way to inject that setting in a `sage -t` run ? It would be good to find if there are any other undiagnosed masked infinite recursions in the sage doctests. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
[sage-devel] Re: using infinite recursion productively
2016-05-19 16:49:24 UTC+2, Nils Bruin: > > You can use infinite recursion productively in python. It even evaluates > pretty quickly: > > We've used it in the sage library in at least two places (although > one was rewritten a while ago to use a different mechanism). > Could you tell which two places you have in mind? -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.